t00f
unread,Jun 3, 2011, 7:39:35 AM6/3/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jsonpickle
Hi guys,
First, I would like to thank you for the very useful jsonpickle
module.
I am trying to use your library in order to encode / decode SQLAlchemy
objects. JSON giving by the pickler.encode(obj, unpicklable=False)
method always give me an additional key named "_sa_instance_state".
This key provides a complete information about the object but does not
really make sense to be shown in my JSON representation.
For exemple, if I have a Person object (id, name) :
>>> p = Person('XXXXX')
>>> jsonpickle.encode(p, unpicklable=False)
'{"id": "XX", "name": "XXXXX", "_sa_instance_state": {"py/state":
{"instance": {"py/ref": "/"}, "callables": {}, "parents":
{"173984236": true}, "modified": true, "committed_state": {"code":
{"name": "NEVER_SET"}, "name": {"name": "NO_VALUE"}}}}}'
I am looking for a solution to remove this entry. I checked the source
code of jsonpickle and found that the flatten method pop out some
stuff. Is there any way to tell the library which keys has to be
deleted ?
I don't really want to fork the library, but I am thinking about
something like a method to pass a list of keywords to avoid keeping in
the JSON representation.
What do you think about this problem ? Do you have any current
solution to deal with it ?
Thanks for your time,
Best regards,
t00f