Registry / serialization / jsonpickle

jsonpickle

JSON →
library4.1.2pypypi✓ verified 25d ago

jsonpickle is a Python library for serialization and deserialization of complex Python objects to and from JSON. It extends standard JSON encoders to handle more complex data structures than what Python's `json` module natively supports. As of version 4.1.1, the project is actively maintained with a regular release cadence.

pip install jsonpickle
INSTALL
IMPORT
SIG · JSONPICKLE
J
jsonpickle
serializationpythonv4.1.2
Install
1.7s avg
Import
147ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.154s · 18.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.140s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jsonpickle
import jsonpickle

This quickstart demonstrates encoding a custom Python object (a dataclass instance) into a JSON string and then decoding it back into a Python object using `jsonpickle.encode` and `jsonpickle.decode`.

import jsonpickle from dataclasses import dataclass @dataclass class MyObject: name: str value: int # Create an object original_obj = MyObject(name="Example", value=123) # Encode the object to a JSON string encoded_json = jsonpickle.encode(original_obj) print(f"Encoded JSON: {encoded_json}") # Decode the JSON string back to a Python object decoded_obj = jsonpickle.decode(encoded_json) # Verify the decoded object assert decoded_obj == original_obj print(f"Decoded object: {decoded_obj}")
Debug
Known issues
breakingSecurity Warning: Deserializing untrusted data with `jsonpickle.decode()` can lead to Remote Code Execution (RCE). Like Python's `pickle` module, `jsonpickle` can execute arbitrary code during unpickling if malicious data is provided.
fix
NEVER deserialize data from untrusted sources. If processing untrusted input, use safer serialization methods like the standard `json` module, define explicit schemas, or sign data with an HMAC to ensure integrity.
affects: All versions
breakingPython 3.7 is no longer supported starting with `jsonpickle` v4.0.0.
fix
Upgrade to Python 3.8 or newer to use `jsonpickle` v4.x.
affects: >=4.0.0
breakingThe default value of the `safe` parameter in `jsonpickle.decode()` changed from `False` to `True` in v4.0.0. Setting `safe=False` enables backwards-compatible deserialization of `repr`-serialized objects but uses `eval()` and is not secure against malicious inputs.
fix
Ensure you are not explicitly setting `safe=False` when dealing with untrusted input. The default `safe=True` is recommended for security. If you need to decode old data, re-pickle it with a newer version.
affects: >=4.0.0
deprecatedThe `jsonpickle.compat` module is no longer used internally and may be removed in a future version (e.g., v5.0.0).
fix
Avoid direct usage of `jsonpickle.compat` and its functions. Review `CHANGES.rst` for specific function deprecations that might affect your code.
affects: >=4.0.1
deprecatedCertain utility functions in `jsonpickle/util.py` were deprecated in v4.1.0 and are planned for removal in v5.0.0 to facilitate static typing. Additionally, `jsonpickle.ext.yaml` will no longer be registered by default in v5.0.0.
fix
Review your code for direct calls to functions within `jsonpickle.util` or reliance on `jsonpickle.ext.yaml` being automatically registered. Migrate away from these as v5.0.0 approaches.
affects: >=4.1.0
Errors
Common errors & fixes
ImportError: No module named 'jsonpickle'
The jsonpickle library is not installed or not accessible in your current Python environment.
fix
Run `pip install jsonpickle` to install the library.
jsonpickle.decode returns dict instead of object
When deserializing, the original class definition for the object is not globally accessible in the current Python environment, or the object was encoded with `unpicklable=False`, which strips type metadata.
fix
Ensure the custom class definition is imported and available in the global scope when calling `jsonpickle.decode()`. If `unpicklable=False` was used during encoding, `jsonpickle` cannot reconstruct the original object type, and you will receive a dictionary representation.
jsonpickle deserialization vulnerability Remote Code Execution
Deserializing untrusted JSON data with `jsonpickle.decode()` can lead to arbitrary code execution, as `jsonpickle` is designed to reconstruct complex Python objects and methods, similar to the `pickle` module.
fix
Never use `jsonpickle.decode()` on data from untrusted or unvalidated sources. For untrusted data, use standard JSON parsing (`json.loads`) and validate against explicit schemas. If using `jsonpickle` is necessary, ensure `safe=True` is passed to `decode()` and understand its limitations.
AttributeError: 'OrderedDict' object has no attribute '_OrderedDict__root'
This specific `AttributeError` can occur during `jsonpickle.decode()` when an `OrderedDict` object, possibly originating from a specific library version (e.g., older `requests` versions), is being restored and lacks an expected internal attribute that `jsonpickle` attempts to access.
fix
Upgrade `jsonpickle` to the latest version. If the problem persists, try upgrading the conflicting library (e.g., `requests`). As a workaround, you might convert `OrderedDict` instances to standard `dict` objects before serialization if their order is not critical for deserialization outside of the original context.
Upgrade
Version history
4.1.2latest on PyPI · released May 28, 2026
Audit
Dependencies
numpyoptionalOptional: For serializing NumPy arrays and models via jsonpickle.ext.numpy.
pandasoptionalOptional: For serializing Pandas DataFrames and other data types via jsonpickle.ext.pandas.
gmpy2optionalOptional: For serializing ecdsa module's keys.
simplejsonoptionalOptional: Can be used as an alternative JSON backend.
ujsonoptionalOptional: Can be used as an alternative JSON backend.
PyYAMLoptionalOptional: For YAML backend support via jsonpickle.ext.yaml.
Agent activity
7 hits · last 30 days
node
6
Resources
jsonpickle — pip install jsonpickle · libregistry