An improved jsonpickle mkref format

Skip to first unread message

David Aguilar

Jun 18, 2011, 10:56:15 PM6/18/11
to, 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:

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

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.

John Paulett

Jun 21, 2011, 1:25:09 PM6/21/11
to, Eoghan Murray, Grant Limberg

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.


> --
> You received this message because you are subscribed to the Google Groups "jsonpickle" group.
> To post to this group, send email to
> To unsubscribe from this group, send email to
> For more options, visit this group at

Reply all
Reply to author
0 new messages