<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Serializing arbitrary Python objects to JSON using __dict__</title>
	<atom:link href="http://www.marcstober.com/blog/2007/07/07/serializing-arbitrary-python-objects-to-json-using-__dict__/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marcstober.com/blog/2007/07/07/serializing-arbitrary-python-objects-to-json-using-__dict__/</link>
	<description>// Repairing the world, one byte at a time. Marc Stober&#039;s blog.</description>
	<lastBuildDate>Wed, 06 Jul 2011 20:21:00 -0700</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: John</title>
		<link>http://www.marcstober.com/blog/2007/07/07/serializing-arbitrary-python-objects-to-json-using-__dict__/comment-page-1/#comment-12243</link>
		<dc:creator>John</dc:creator>
		<pubDate>Thu, 20 Mar 2008 05:34:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.marcstober.com/blog/2007/07/07/serializing-arbitrary-python-objects-to-json-using-__dict__/#comment-12243</guid>
		<description>Marc, I definitely agree with your approach.  I was working on a similar solution when I saw your post.  I just released an alpha version of a library for handling more complex object serialization, jsonpickle (http://code.google.com/p/jsonpickle/).  

Cheers</description>
		<content:encoded><![CDATA[<p>Marc, I definitely agree with your approach.  I was working on a similar solution when I saw your post.  I just released an alpha version of a library for handling more complex object serialization, jsonpickle (<a href="http://code.google.com/p/jsonpickle/" rel="nofollow">http://code.google.com/p/jsonpickle/</a>).  </p>
<p>Cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GreenTea</title>
		<link>http://www.marcstober.com/blog/2007/07/07/serializing-arbitrary-python-objects-to-json-using-__dict__/comment-page-1/#comment-8467</link>
		<dc:creator>GreenTea</dc:creator>
		<pubDate>Fri, 10 Aug 2007 17:15:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.marcstober.com/blog/2007/07/07/serializing-arbitrary-python-objects-to-json-using-__dict__/#comment-8467</guid>
		<description>Thank you for this post. It is definitely helping me today. Here are some code corrections and printing that may assist others.

#!/usr/bin/python
import sys, traceback, pdb

import simplejson

class Person:
        def __init__(self, name=None):
                if not name:
                        self.name = self.namepeople = [ Person(&#039;Marc&#039;), Person(&#039;Rachel&#039;) ]
                else:
                        self.name = name

pdb.set_trace()

people = Person()
# Fails with error that Field class &quot;is not JSON serializable&quot;
#s = simplejson.dumps(fields)

# This is what we want.
print &quot;-------------------------------------&quot;
print &quot;dumps&quot;
print &quot;-------------------------------------&quot;
s = simplejson.dumps([p.__dict__ for p in people.namepeople])
print s

# Deserialize
print &quot;-------------------------------------&quot;
print &quot;load clones&quot;
print &quot;-------------------------------------&quot;
clones = simplejson.loads(s)
print clones

# Now give our clones some life
for clone in clones:
        p = Person()
        p.__dict__ = clone
        print &quot;-------------------------------------&quot;
        print &quot;instantiate clones&quot;
        print &quot;-------------------------------------&quot;
        print p
        print p.name</description>
		<content:encoded><![CDATA[<p>Thank you for this post. It is definitely helping me today. Here are some code corrections and printing that may assist others.</p>
<p>#!/usr/bin/python<br />
import sys, traceback, pdb</p>
<p>import simplejson</p>
<p>class Person:<br />
        def __init__(self, name=None):<br />
                if not name:<br />
                        self.name = self.namepeople = [ Person('Marc'), Person('Rachel') ]<br />
                else:<br />
                        self.name = name</p>
<p>pdb.set_trace()</p>
<p>people = Person()<br />
# Fails with error that Field class &#8220;is not JSON serializable&#8221;<br />
#s = simplejson.dumps(fields)</p>
<p># This is what we want.<br />
print &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221;<br />
print &#8220;dumps&#8221;<br />
print &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221;<br />
s = simplejson.dumps([p.__dict__ for p in people.namepeople])<br />
print s</p>
<p># Deserialize<br />
print &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221;<br />
print &#8220;load clones&#8221;<br />
print &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221;<br />
clones = simplejson.loads(s)<br />
print clones</p>
<p># Now give our clones some life<br />
for clone in clones:<br />
        p = Person()<br />
        p.__dict__ = clone<br />
        print &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221;<br />
        print &#8220;instantiate clones&#8221;<br />
        print &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221;<br />
        print p<br />
        print p.name</p>
]]></content:encoded>
	</item>
</channel>
</rss>

