title: What's Python JSON serializable?
body: <p>I have two ways to represent Python object by <code>json.dumps()</code></p>
  <p>First:</p>
  <pre><code>person = {
  &quot;name&quot;: &quot;John&quot;,
  &quot;age&quot;: 30,
  &quot;city&quot;: &quot;New York&quot;
  }
  </code></pre>
  <p>Second:</p>
  <pre><code>class Person:
     def _init_(self, name, age, city):
        self.name = name
        self.age = age
        self.city = city
  
  person = Person(&quot;John&quot;, 30, &quot;New York&quot;)
  </code></pre>
  <p>Then I tried <code>p1 = json.dumps(person)</code>, the second way would say <code>it's not JSON serializable</code>.</p>
  <p>So basically for Python, json.dumps only work for built-in object like dict object?</p>