An improved jsonpickle mkref format

22 views
Skip to first unread message

David Aguilar

unread,
Jun 18, 2011, 10:56:15 PM6/18/11
to jsonp...@googlegroups.com, Eoghan Murray, Grant Limberg

I've updated the jsonpickle mkref format to better support
cyclical data structures.

The original format used an "xpath"-like string when referencing
objects. This broke down when the objects it needed to
referenced lived inside of a list.

The new format is based on IDs which are sequentially assigned
during the object graph traversal. This is a much more robust
format and solves the problem of referencing into child lists
and saves us from having to invent a syntax for doing so.

This was motivated by issue #12:

https://github.com/jsonpickle/jsonpickle/issues/12
https://gist.github.com/712554

...and other discussions about this topic in the past.

I made sure to keep backwards-compatibility so that jsonpickle
can still read json written by earlier versions of jsonpickle.
The new pickler, though, only writes the new format. This
will allow users to migrate to the new format seemlessly,
but they will need to be aware that only new clients can read
json written by the new version.

My pull request is here:

https://github.com/jsonpickle/jsonpickle/pull/16

It'd be great to get some feedback about the new format.
I'm actually quite pleased with its simplicity.

Later work (namely, some of the more advanced stuff
where objects appear as keys) might be able to leverage
the work done here, hopefully.
--
David

John Paulett

unread,
Jun 21, 2011, 1:25:09 PM6/21/11
to jsonp...@googlegroups.com, Eoghan Murray, Grant Limberg
David,

Thanks for contributing this improvement! It looks good to me, I have
merged it into jsonpickle/master.

Grant & Eoghan, thanks for reporting the issue & providing test cases!

I bundled up the latest changes and just released 0.4.0 to pypi (sorry
for the long delay). If anyone notices any issues, let me know.

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.
>
>

Reply all
Reply to author
Forward
0 new messages