<div dir="ltr"><div><div><div><div>Hi,<br><br></div>indeed these objects are not serializable with the well known Python's JSON serializers.<br></div>I would suggest you jsonpickle that allows the serialization that you need: <a href="http://jsonpickle.github.io/">http://jsonpickle.github.io/</a><br>

<br></div>good luck!<br></div>-Francesco<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 11 January 2014 18:46, Marco Olimpi <span dir="ltr"><<a href="mailto:badstorm@gmail.com" target="_blank">badstorm@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi, <div>i'm traing to serialize my called in python. This is my example:</div><div>I have this two classes:</div>

<div><br></div><div><b>class User():</b></div><div><b>  def __init__(self, _name, _lastname):</b></div>
<div><b>       self.Name = _name</b></div><div><b>       self.LastName = _lastname</b></div><div><b><br></b></div><div><b>class News():</b></div><div><b>  def __init__(self, _news,_user):</b></div><div><b>       self.News = _news</b></div>


<div><b>       self.User = _user</b></div><div><br></div><div><br></div><div>than i create my class in my code:</div><div><br></div><div>...</div><div><b>myUser = User("Mario","Rossi")</b></div><div><b>myNews = News("My last news", myUser)</b></div>


<div><b><br></b></div><div><b>JSONstring = dumps(myNews)</b></div><div>...</div><div><br></div><div>but in the last line of code i get the error that the News class is not JSON serializable.</div><div><br></div><div>How I can make this work?</div>


<div><br></div><div>Thanks.</div><div><br></div><div>Regards</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Marco</div></font></span></div>
<br>_______________________________________________<br>
Python mailing list<br>
<a href="mailto:Python@lists.python.it">Python@lists.python.it</a><br>
<a href="http://lists.python.it/mailman/listinfo/python" target="_blank">http://lists.python.it/mailman/listinfo/python</a><br>
<br></blockquote></div><br></div>