Interesting. I've never tried JP with these objects. can you fork the repo on github and perhaps commit a (failure-expecting) test case? hopefully we can figure out a simple solution.
until then, you may be able to register a serialization handler for those classes.
I'm leaving to Europe for two weeks so I won't be able to dig in for a little bit but having the testcase would be very helpful. feel free to fork and experiment.
https://github.com/jsonpickle/jsonpickle
thanks,
--
David
The relevant code will likely be in jsonpickle.pickler's flatten() and
_flatten_obj_instance()
https://github.com/jsonpickle/jsonpickle/blob/master/jsonpickle/pickler.py#L72
defaultdict is a subclass of dict, so the check for default dict
probably needs to be handled before we handle normal dicts.
The stdlib pickle module handles defaultdict perfectly fine, so it
would be nice to include this in jsonpickle.
John
> --
> You received this message because you are subscribed to the Google Groups "jsonpickle" group.
> To post to this group, send email to jsonp...@googlegroups.com.
> To unsubscribe from this group, send email to jsonpickle+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jsonpickle?hl=en.
>
>
Do you happen to have an example of what these objects look like?
Maybe a quick snippet of python to show me what you expect to see?
I'm just getting back to the states now. I'll try and look into it
later this week.
--
David
I pushed some changes to my github fork's "collections" branch.
They add support for collections.defaultdict. Your sample code is in
a test case now so it'll always work.
We're going to need to look at the rest of the classes in collections
and find the best way to support them in (a generic way), if possible.
RE: Performance -- I've never done a micro-optimization pass over the
code but I'm sure it could shave some msecs here and there. Of
course, finalizing on the JSON format and doing it in C would be the
fastest, but no one's needed that kind of speed yet. A streaming API
would be interesting.
Let us know how it goes. Code reviews (and patches) are highly appreciated :-)
cheers,
--
David