title: 'str' object has no attribute '__dict__'
body: <p>I want to serialize a dictionary to JSON in Python. I have this 'str' object has no attribute '<strong>dict</strong>' error. Here is my code...</p>
  
  <pre><code>from django.utils import simplejson
  
  class Person(object):
      a = ""
  
  person1 = Person()
  person1.a = "111"
  
  person2 = Person()
  person2.a = "222"
  
  list = {}
  list["first"] = person1
  list["second"] = person2
  
  s = simplejson.dumps([p.__dict__ for p in list])
  </code></pre>
  
  <p>And the exception is;</p>
  
  <pre><code>Traceback (most recent call last):
    File "/base/data/home/apps/py-ide-online/2.352580383594527534/shell.py", line 380, in post
      exec(compiled_code, globals())
    File "&lt;string&gt;", line 17, in &lt;module&gt;
  AttributeError: 'str' object has no attribute '__dict__'
  </code></pre>