I could... but I'm trying not to :)<div><div><br></div><div>I think I found what I was looking for: Linaro-python-json <a href="https://launchpad.net/linaro-python-json/">https://launchpad.net/linaro-python-json/</a></div>
<div><br></div><div><a href="https://launchpad.net/linaro-python-json/"></a>From the docs:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>
>>> class Person(IComplexJSONType):</div></div><div><div>... def __init__(self, name):</div></div><div><div>... <a href="http://self.name">self.name</a> = name</div></div><div><div>... def to_json(self):</div>
</div><div><div>... return {'name': <a href="http://self.name">self.name</a>}</div></div><div><div><br></div></div><div><div>Let's make a person instance:</div></div><div><div>>>> joe = Person('Joe')</div>
</div><div><div>>>> <a href="http://joe.name">joe.name</a></div></div><div><div>'Joe'</div></div><div><div><br></div></div><div><div>We can now serialize this object using json.dumps() or any other json</div>
</div><div><div>module API. The only requirement is to pass our generic pluggable</div></div><div><div>encoder class:</div></div><div><div>>>> json.dumps(joe, cls=PluggableJSONEncoder, class_hint=None)</div></div>
<div><div>'{"name": "Joe"}'</div></div></blockquote><div><div><br><div class="gmail_quote"><br></div><div class="gmail_quote">I might have a play with it at some point to see whether it is a net gain. It's certainly pretty similar to what I was thinking. Thanks for your suggestions, guys.</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">--Mark</div><div class="gmail_quote"><br></div><div class="gmail_quote">On 11 January 2011 14:06, John Sutherland <span dir="ltr"><<a href="mailto:john@sneeu.com">john@sneeu.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Surely you could knock something together rather quickly with<br>
simplejson, and the magic __dict__ attribute of objects?<br>
<br>
John.<br>
<font color="#888888"><br>
<br>
--<br>
<a href="http://sneeu.com" target="_blank">sneeu.com</a><br>
"A computer shall not waste your time or require you to do more work than is<br>
strictly necessary" – Jef Raskin.<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Edinburgh mailing list<br>
<a href="mailto:Edinburgh@python.org">Edinburgh@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/edinburgh" target="_blank">http://mail.python.org/mailman/listinfo/edinburgh</a><br>
</div></div></blockquote></div><br></div></div></div>