jsonpickle

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.

https://github.com/jsonpickle/jsonpickle

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    5 of 82 committers (6.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.2%) to scientific vocabulary

Keywords

bsd-3-clause deserialization json objectstorage pickle python serialization

Keywords from Contributors

closember distribution unit-testing asyncio fuzzing parsing osx pallets aiohttp http-client
Last synced: 6 months ago · JSON representation

Repository

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.

Basic Info
Statistics
  • Stars: 1,295
  • Watchers: 31
  • Forks: 176
  • Open Issues: 63
  • Releases: 9
Topics
bsd-3-clause deserialization json objectstorage pickle python serialization
Created about 16 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog Funding License Security

README.rst

.. image:: https://img.shields.io/pypi/v/jsonpickle.svg
   :target: `PyPI link`_

.. image:: https://img.shields.io/pypi/pyversions/jsonpickle.svg
   :target: `PyPI link`_

.. _PyPI link: https://pypi.org/project/jsonpickle

.. image:: https://readthedocs.org/projects/jsonpickle/badge/?version=latest
   :target: https://jsonpickle.readthedocs.io/en/latest/?badge=latest

.. image:: https://github.com/jsonpickle/jsonpickle/actions/workflows/test.yml/badge.svg
   :target: https://github.com/jsonpickle/jsonpickle/actions
   :alt: Github Actions

.. image:: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg
   :target: https://github.com/jsonpickle/jsonpickle/blob/main/LICENSE
   :alt: BSD


jsonpickle
==========

jsonpickle is a library for the two-way conversion of complex Python objects
and `JSON `_.  jsonpickle builds upon existing JSON
encoders, such as simplejson, json, and ujson.

.. warning::

   jsonpickle can execute arbitrary Python code.

   Please see the Security section for more details.


For complete documentation, please visit the
`jsonpickle documentation `_.

Bug reports and merge requests are encouraged at the
`jsonpickle repository on github `_.

Usage
=====
The following is a very simple example of how one can use jsonpickle in their scripts/projects. Note the usage of jsonpickle.encode and decode, and how the data is written/encoded to a file and then read/decoded from the file.

.. code-block:: python

   import jsonpickle
   from dataclasses import dataclass


   @dataclass
   class Example:
       data: str


   ex = Example("value1")
   encoded_instance = jsonpickle.encode(ex)
   assert encoded_instance == '{"py/object": "__main__.Example", "data": "value1"}'

   with open("example.json", "w+") as f:
       f.write(encoded_instance)

   with open("example.json", "r+") as f:
       written_instance = f.read()
       decoded_instance = jsonpickle.decode(written_instance)
   assert decoded_instance == ex

For more examples, see the `examples directory on GitHub `_ for example scripts. These can be run on your local machine to see how jsonpickle works and behaves, and how to use it. Contributions from users regarding how they use jsonpickle are welcome!


Why jsonpickle?
===============

Data serialized with python's pickle (or cPickle or dill) is not easily readable outside of python. Using the json format, jsonpickle allows simple data types to be stored in a human-readable format, and more complex data types such as numpy arrays and pandas dataframes, to be machine-readable on any platform that supports json. E.g., unlike pickled data, jsonpickled data stored in an Amazon S3 bucket is indexible by Amazon's Athena.

Security
========

jsonpickle should be treated the same as the
`Python stdlib pickle module `_
from a security perspective.

.. warning::

   The jsonpickle module **is not secure**.  Only unpickle data you trust.

   It is possible to construct malicious pickle data which will **execute
   arbitrary code during unpickling**.  Never unpickle data that could have come
   from an untrusted source, or that could have been tampered with.

   Consider signing data with an HMAC if you need to ensure that it has not
   been tampered with.

   Safer deserialization approaches, such as reading JSON directly,
   may be more appropriate if you are processing untrusted data.


Install
=======

Install from pip for the latest stable release:

::

    pip install jsonpickle

Install from github for the latest changes:

::

    pip install git+https://github.com/jsonpickle/jsonpickle.git


Numpy/Pandas Support
====================

jsonpickle includes built-in numpy and pandas extensions.  If you would
like to encode sklearn models, numpy arrays, pandas DataFrames, and other
numpy/pandas-based data, then you must enable the numpy and/or pandas
extensions by registering their handlers::

    >>> import jsonpickle.ext.numpy as jsonpickle_numpy
    >>> import jsonpickle.ext.pandas as jsonpickle_pandas
    >>> jsonpickle_numpy.register_handlers()
    >>> jsonpickle_pandas.register_handlers()


Development
===========

Use `make` to run the unit tests::

        make test

`pytest` is used to run unit tests internally.

A `tox` target is provided to run tests using all installed and supported Python versions::

        make tox

`jsonpickle` itself has no dependencies beyond the Python stdlib.
`tox` is required for testing when using the `tox` test runner only.

The testing requirements are specified in `setup.cfg`.
It is recommended to create a virtualenv and run tests from within the
virtualenv.::

        python3 -mvenv env3
        source env3/bin/activate
        pip install --editable '.[dev]'
        make test

You can also use a tool such as `vx `_
to activate the virtualenv without polluting your shell environment::

        python3 -mvenv env3
        vx env3 pip install --editable '.[dev]'
        vx env3 make test

If you can't use a venv, you can install the testing packages as follows::

        pip install .[testing]

`jsonpickle` supports multiple Python versions, so using a combination of
multiple virtualenvs and `tox` is useful in order to catch compatibility
issues when developing.


Related Links and Projects
==========================
* `jsonpickleJS `_ was a sister
project of jsonpickle for implementing similar functionality but in Javascript.
The last release was in August 2025.


GPG Signing
===========

Unfortunately, while versions of jsonpickle before 3.0.1 should still be signed,
GPG signing support was removed from PyPi
(https://blog.pypi.org/posts/2023-05-23-removing-pgp/) back in May 2023.

License
=======

Licensed under the BSD License. See the LICENSE file for more details.

Owner

  • Name: jsonpickle
  • Login: jsonpickle
  • Kind: organization

GitHub Events

Total
  • Create event: 15
  • Release event: 9
  • Issues event: 33
  • Watch event: 52
  • Delete event: 1
  • Issue comment event: 86
  • Push event: 54
  • Pull request review comment event: 13
  • Pull request event: 54
  • Pull request review event: 35
  • Fork event: 5
Last Year
  • Create event: 15
  • Release event: 9
  • Issues event: 33
  • Watch event: 52
  • Delete event: 1
  • Issue comment event: 86
  • Push event: 54
  • Pull request review comment event: 13
  • Pull request event: 54
  • Pull request review event: 35
  • Fork event: 5

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 1,444
  • Total Committers: 82
  • Avg Commits per committer: 17.61
  • Development Distribution Score (DDS): 0.553
Past Year
  • Commits: 150
  • Committers: 9
  • Avg Commits per committer: 16.667
  • Development Distribution Score (DDS): 0.327
Top Committers
Name Email Commits
David Aguilar d****d@g****m 646
Jason R. Coombs j****o@j****m 252
Theelx 4****x 183
John Paulett j****n@p****g 47
davvid d****d@b****b 42
john.paulett j****t@b****b 22
Eelco Hoogendoorn h****o@g****m 22
Theelgirl r****t@l****m 20
Theelgirl 4****l 19
Ivan Smirnov i****v@g****m 16
Marcin Tustin m****n@g****m 15
Hugo van Kemenade h****k 10
Kyle Parsons p****9@g****m 9
almenon a****4@g****m 7
paulocheque p****e@g****m 6
Dan Buch d****h@g****m 6
Eoghan Murray e****n@e****) 6
Graham Esau g****u@h****k 5
David Lakin g****b@t****m 5
Alec Thomas a****c@s****g 5
Aviram Stern a****n@p****m 5
Michael Scott Cuthbert c****t@m****u 5
Tomasz Kłoczko k****k@g****m 4
dheeraj.reddy d****y@t****m 4
simi.legian g****b@l****m 4
Effie Rozental e****e@s****o 3
Stefan Tjarks s****n@d****t 3
Michał Górny m****y@g****g 3
Martin K. Scherer m****r@f****e 3
Colin Watson c****n@d****g 2
and 52 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 107
  • Total pull requests: 120
  • Average time to close issues: 9 months
  • Average time to close pull requests: 6 days
  • Total issue authors: 90
  • Total pull request authors: 24
  • Average comments per issue: 3.96
  • Average comments per pull request: 1.48
  • Merged pull requests: 115
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 13
  • Pull requests: 37
  • Average time to close issues: 3 days
  • Average time to close pull requests: 2 days
  • Issue authors: 13
  • Pull request authors: 6
  • Average comments per issue: 1.0
  • Average comments per pull request: 1.03
  • Merged pull requests: 37
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Theelx (6)
  • yurivict (4)
  • jaraco (3)
  • mgorny (3)
  • limburgher (3)
  • GREsau (2)
  • DeveloperAnonymous (2)
  • antoinecollet5 (2)
  • jrobbins-LiveData (2)
  • steinmig (1)
  • RRRajput (1)
  • alexeykomp (1)
  • effierz (1)
  • jelly (1)
  • brandonschabell (1)
Pull Request Authors
  • Theelx (73)
  • davvid (63)
  • GREsau (4)
  • cjwatson (4)
  • dwagon (4)
  • mgorny (3)
  • DaveLak (2)
  • bhaveshpandey (2)
  • Squadrick (2)
  • cdce8p (2)
  • kloczek (2)
  • similegian (1)
  • erogers88 (1)
  • effierz (1)
  • perrinjerome (1)
Top Labels
Issue Labels
bug (20) enhancement (15) not-a-bug (14) good-first-issue (10) core (9) wishlist (8) documentation (5) compatibility (5) extensions (4) has-MRE (3) cannot-reproduce (2) security (2) needs-author-action (2) performance (1) not-a-jsonpickle-bug (1) breaking-change (1) testcase-needed (1)
Pull Request Labels
breaking-change (2)

Packages

  • Total packages: 5
  • Total downloads:
    • pypi 15,123,644 last-month
  • Total docker downloads: 1,541,283,015
  • Total dependent packages: 422
    (may contain duplicates)
  • Total dependent repositories: 9,336
    (may contain duplicates)
  • Total versions: 125
  • Total maintainers: 5
  • Total advisories: 1
pypi.org: jsonpickle

jsonpickle encodes/decodes any Python object to/from JSON

  • Versions: 59
  • Dependent Packages: 404
  • Dependent Repositories: 9,284
  • Downloads: 15,123,644 Last month
  • Docker Downloads: 1,541,283,015
Rankings
Docker downloads count: 0.0%
Dependent packages count: 0.1%
Downloads: 0.1%
Dependent repos count: 0.1%
Average: 1.3%
Stargazers count: 2.6%
Forks count: 5.1%
Maintainers (4)
Last synced: 6 months ago
proxy.golang.org: github.com/jsonpickle/jsonpickle
  • Versions: 43
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 1.9%
Forks count: 2.1%
Average: 6.1%
Dependent packages count: 9.6%
Dependent repos count: 10.8%
Last synced: 6 months ago
conda-forge.org: jsonpickle
  • Versions: 10
  • Dependent Packages: 14
  • Dependent Repositories: 26
Rankings
Dependent packages count: 4.5%
Dependent repos count: 7.2%
Average: 9.6%
Stargazers count: 12.0%
Forks count: 14.6%
Last synced: 6 months ago
spack.io: py-jsonpickle

Python library for serializing any arbitrary object graph into JSON.

  • Versions: 3
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Stargazers count: 6.9%
Forks count: 8.3%
Average: 10.8%
Dependent packages count: 28.1%
Maintainers (1)
Last synced: 6 months ago
anaconda.org: jsonpickle

jsonpickle is a library for the two-way conversion of complex Python objects and JSON. jsonpickle builds upon the existing JSON encoders, such as simplejson, json, and ujson.

  • Versions: 10
  • Dependent Packages: 3
  • Dependent Repositories: 26
Rankings
Dependent packages count: 20.4%
Stargazers count: 22.6%
Average: 24.9%
Forks count: 26.4%
Dependent repos count: 30.0%
Last synced: 6 months ago

Dependencies

docs/requirements.txt pypi
  • Sphinx *
  • jaraco.packaging *
  • rst.linker *
requirements-dev.txt pypi
  • bson *
  • coverage <5
  • ecdsa *
  • feedparser *
  • gmpy2 *
  • numpy *
  • pandas *
  • pymongo *
  • pytest *
  • pytest-benchmark *
  • pytest-cov *
  • pytest-flake8 >=1.1.1
  • scikit-learn *
  • simplejson *
  • sqlalchemy >=1.2.19
  • ujson *
.github/workflows/lint.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
  • isort/isort-action master composite
  • psf/black stable composite
  • stefanzweifel/git-auto-commit-action v4 composite
.github/workflows/test.yml actions
  • actions/cache v3 composite
  • actions/checkout v2 composite
  • actions/setup-python v4 composite