Hi, again:<div><br></div><div>I would like to iterate over all items of a returned ResultSet encoding each one using JSON. Example code follows:</div><div><br></div><div><div>class Topic(object):</div><div> __storm_table__= "Trancos.topic" </div>
<div> id = Int(primary=True)</div><div> account_id= Int()</div><div> title= Unicode()</div><div> properties= Unicode()</div><div> notes= Unicode()</div></div><div> # and other attrs not important here ...</div>
<div><br></div><div>def do_query():</div><div> ''' Query'''</div><div><div> engine= create_database("postgres://postgres:mypassword@localhost/trancos")</div><div> store= Store(engine)</div>
<div> </div><div> # execute the query and iterate over the ResultSet</div><div> rs= store.find(Topic)</div><div> for t in rs:</div><div> print <a href="http://t.id">t.id</a>, json.dumps(t)</div></div><div>
<br></div><div>But I get the error:</div><div><br></div><div><div> File "/usr/lib/python2.6/json/encoder.py", line 344, in default</div><div> raise TypeError(repr(o) + " is not JSON serializable")</div>
<div>TypeError: <__main__.Topic object at 0x26f3090> is not JSON serializable</div></div><div><br clear="all">Any ideas ? Is there a way to serialize a Storm object (or a full ResultSet) to JSON ?</div><div><br></div>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div>Sorry if this a strict Python language item !</div><div><br></div><div>Thanks.</div><div>Mario</div><div><br>-- <br>Mario A. Zito<br>ANALYTE SRL<br><a href="http://www.analyte.com">www.analyte.com</a><br>
</div><div><br></div>