jsonpickle/jsonpickle — pull request #91 by lieryan (2014-09-16 03:11:29+00:00)
Title: pickler: escape string that have special meaning when used as dictionary key

When keys=True, jsonpickle currently encodes

In [1]: original = {'json://6': 6}

In [2]: encode(original, keys=True)
Out[2]: '{"json://6": 6}'

which when reconstituted becomes:

In [3]: decode(encode(original, keys=True), keys=True)
Out[3]: {6: 6}

This pull request changes the JSON string to:

In [1]: original = {'json://6': 6}

In [2]: encode(original, keys=True)
Out[2]: '{"json://\\"json://6\\"": 6}'

which would be correctly reconstituted to:

In [3]: decode(encode(original, keys=True), keys=True)
Out[3]: {'json://6': 6}