title: python json.dumps: unable to ignore non serializable objects
body: <p>In python when i want to pretty print an object during debugging i use </p>
  
  <pre><code>print(json.dumps(obj.__dict__), indent=4, sort_keys=True)
  </code></pre>
  
  <p>because just using <code>print(obj)</code> is not very readable</p>
  
  <p>Then if some of the items are non serialzable it says</p>
  
  <pre><code>Object of type SOMETHING is not JSON serializable
  </code></pre>
  
  <p>So my goal is to just check an object while debugging and not to have a perfectly serialized object to pass it and later convert back.</p>
  
  <p>I tried the following by adding <code>default=str</code> to avoid the error and it worked in many cases</p>
  
  <pre><code>print(json.dumps(obj.__dict__), indent=4, sort_keys=True, default=str)
  </code></pre>
  
  <p>But still in some cases it shows</p>
  
  <pre><code>Object of type SOMETHING is not JSON serializable
  </code></pre>
  
  <p>So how to solve this.</p>
  
  <p>The object i am trying is from Django project. I am trying to pretty print using the help of <code>json.dumps</code></p>
  
  <pre><code>from django.db import connections
  import json
  for c in connections.all():
      c_dict = {k: getattr(c, k) for k in dir(c)} # this gives all the properties listed using dir(c)
      print(json.dumps(c_dict), indent=4, sort_keys=True, default=str)
  </code></pre>
  
  <p><strong>ANSWER:</strong></p>
  
  <p>@milanbalanz answered it in the comments. Its a <code>typo error</code> of the brackets. So <code>default=str</code> works as its indented to
  the wrong one is </p>
  
  <pre><code>print(json.dumps(c_dict), indent=4, sort_keys=True, default=str)
  </code></pre>
  
  <p>the right one is</p>
  
  <pre><code>print(json.dumps(c_dict, indent=4, sort_keys=True, default=str))
  </code></pre>