Python library for serializing any arbitrary object graph into JSON. It can take almost any Python object and turn the object into JSON. Additionally, it can reconstitute the object back into Python.
>>> import jsonpickle >>> from samples import Thing
Create an object.
>>> obj = Thing('A String')
>>> print obj.name
A String
Use jsonpickle to transform the object into a JSON string.
>>> pickled = jsonpickle.encode(obj)
>>> print pickled
{"py/object": "samples.Thing", "name": "A String", "child": null}
Use jsonpickle to recreate a Python object from a JSON string
>>> unpickled = jsonpickle.decode(pickled) >>> str(unpickled.name) 'A String'
The new object has the same type and data, but essentially is now a copy of the original.
>>> obj == unpickled False >>> obj.name == unpickled.name True >>> type(obj) == type(unpickled) True
If you will never need to load (regenerate the Python class from JSON), you can pass in the keyword unpicklable=False to prevent extra information from being added to JSON.
>>> oneway = jsonpickle.encode(obj, unpicklable=False)
>>> print oneway
{"name": "A String", "child": null}
Metadata
Release files for jsonpickle 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jsonpickle-0.3.0.tar.gz | 10.1 kB | Details |
Release files / jsonpickle-0.3.0.tar.gz
| Download URL | jsonpickle-0.3.0.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
724ce15d758a3e210041b22576ab7626eed550a6841d9afe52cafa92e2b47aea
|
|
BLAKE2b-256 checksum How to use checksums |
582769aebb2876859f36b1315589d2a1ed7985a2f96177a9c3edece586c764b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |