Debian Codegraph @

PKG-INFO

raw
1 Metadata-Version: 2.1
2 Name: jsonpickle
3 Version: 4.0.2
4 Summary: jsonpickle encodes/decodes any Python object to/from JSON
5 Author: Theelx
6 Author-email: David Aguilar <[email protected]>
7 Project-URL: Documentation, https://jsonpickle.readthedocs.io/
8 Project-URL: Homepage, https://jsonpickle.readthedocs.io/
9 Project-URL: Source, https://github.com/jsonpickle/jsonpickle
10 Classifier: Development Status :: 5 - Production/Stable
11 Classifier: Intended Audience :: Developers
12 Classifier: License :: OSI Approved :: BSD License
13 Classifier: Programming Language :: Python :: 3
14 Classifier: Programming Language :: Python :: 3 :: Only
15 Requires-Python: >=3.8
16 Description-Content-Type: text/x-rst
17 License-File: LICENSE
18 Provides-Extra: cov
19 Requires-Dist: pytest-cov; extra == "cov"
20 Provides-Extra: dev
21 Requires-Dist: black; extra == "dev"
22 Requires-Dist: pyupgrade; extra == "dev"
23 Provides-Extra: testing
24 Requires-Dist: pytest!=8.1.*,>=6.0; extra == "testing"
25 Requires-Dist: pytest-benchmark; extra == "testing"
26 Requires-Dist: pytest-benchmark[histogram]; extra == "testing"
27 Requires-Dist: pytest-checkdocs>=1.2.3; extra == "testing"
28 Requires-Dist: pytest-enabler>=1.0.1; extra == "testing"
29 Requires-Dist: pytest-ruff>=0.2.1; extra == "testing"
30 Requires-Dist: bson; extra == "testing"
31 Requires-Dist: ecdsa; extra == "testing"
32 Requires-Dist: feedparser; extra == "testing"
33 Requires-Dist: gmpy2; extra == "testing"
34 Requires-Dist: numpy; extra == "testing"
35 Requires-Dist: pandas; extra == "testing"
36 Requires-Dist: pymongo; extra == "testing"
37 Requires-Dist: PyYAML; extra == "testing"
38 Requires-Dist: scikit-learn; extra == "testing"
39 Requires-Dist: scipy>=1.9.3; python_version > "3.10" and extra == "testing"
40 Requires-Dist: scipy; python_version <= "3.10" and extra == "testing"
41 Requires-Dist: simplejson; extra == "testing"
42 Requires-Dist: sqlalchemy; extra == "testing"
43 Requires-Dist: ujson; extra == "testing"
44 Requires-Dist: atheris~=2.3.0; python_version < "3.12" and extra == "testing"
45 Provides-Extra: docs
46 Requires-Dist: furo; extra == "docs"
47 Requires-Dist: rst.linker>=1.9; extra == "docs"
48 Requires-Dist: sphinx>=3.5; extra == "docs"
49 Provides-Extra: packaging
50 Requires-Dist: build; extra == "packaging"
51 Requires-Dist: setuptools>=61.2; extra == "packaging"
52 Requires-Dist: setuptools_scm[toml]>=6.0; extra == "packaging"
53 Requires-Dist: twine; extra == "packaging"
54
55 .. image:: https://img.shields.io/pypi/v/jsonpickle.svg
56 :target: `PyPI link`_
57
58 .. image:: https://img.shields.io/pypi/pyversions/jsonpickle.svg
59 :target: `PyPI link`_
60
61 .. _PyPI link: https://pypi.org/project/jsonpickle
62
63 .. image:: https://readthedocs.org/projects/jsonpickle/badge/?version=latest
64 :target: https://jsonpickle.readthedocs.io/en/latest/?badge=latest
65
66 .. image:: https://github.com/jsonpickle/jsonpickle/actions/workflows/test.yml/badge.svg
67 :target: https://github.com/jsonpickle/jsonpickle/actions
68 :alt: Github Actions
69
70 .. image:: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg
71 :target: https://github.com/jsonpickle/jsonpickle/blob/main/COPYING
72 :alt: BSD
73
74
75 jsonpickle
76 ==========
77
78 jsonpickle is a library for the two-way conversion of complex Python objects
79 and `JSON <http://json.org/>`_. jsonpickle builds upon existing JSON
80 encoders, such as simplejson, json, and ujson.
81
82 .. warning::
83
84 jsonpickle can execute arbitrary Python code.
85
86 Please see the Security section for more details.
87
88
89 For complete documentation, please visit the
90 `jsonpickle documentation <http://jsonpickle.readthedocs.io/>`_.
91
92 Bug reports and merge requests are encouraged at the
93 `jsonpickle repository on github <https://github.com/jsonpickle/jsonpickle>`_.
94
95 Usage
96 =====
97 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.
98
99 .. code-block:: python
100
101 import jsonpickle
102 from dataclasses import dataclass
103
104 @dataclass
105 class Example:
106 data: str
107
108
109 ex = Example("value1")
110 encoded_instance = jsonpickle.encode(ex)
111 assert encoded_instance == '{"py/object": "__main__.Example", "data": "value1"}'
112
113 with open("example.json", "w+") as f:
114 f.write(encoded_instance)
115
116 with open("example.json", "r+") as f:
117 written_instance = f.read()
118 decoded_instance = jsonpickle.decode(written_instance)
119 assert decoded_instance == ex
120
121 For more examples, see the `examples directory on GitHub <https://github.com/jsonpickle/jsonpickle/tree/main/examples>`_ 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!
122
123
124 Why jsonpickle?
125 ===============
126
127 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.
128
129 Security
130 ========
131
132 jsonpickle should be treated the same as the
133 `Python stdlib pickle module <https://docs.python.org/3/library/pickle.html>`_
134 from a security perspective.
135
136 .. warning::
137
138 The jsonpickle module **is not secure**. Only unpickle data you trust.
139
140 It is possible to construct malicious pickle data which will **execute
141 arbitrary code during unpickling**. Never unpickle data that could have come
142 from an untrusted source, or that could have been tampered with.
143
144 Consider signing data with an HMAC if you need to ensure that it has not
145 been tampered with.
146
147 Safer deserialization approaches, such as reading JSON directly,
148 may be more appropriate if you are processing untrusted data.
149
150
151 Install
152 =======
153
154 Install from pip for the latest stable release:
155
156 ::
157
158 pip install jsonpickle
159
160 Install from github for the latest changes:
161
162 ::
163
164 pip install git+https://github.com/jsonpickle/jsonpickle.git
165
166
167 Numpy/Pandas Support
168 ====================
169
170 jsonpickle includes built-in numpy and pandas extensions. If you would
171 like to encode sklearn models, numpy arrays, pandas DataFrames, and other
172 numpy/pandas-based data, then you must enable the numpy and/or pandas
173 extensions by registering their handlers::
174
175 >>> import jsonpickle.ext.numpy as jsonpickle_numpy
176 >>> import jsonpickle.ext.pandas as jsonpickle_pandas
177 >>> jsonpickle_numpy.register_handlers()
178 >>> jsonpickle_pandas.register_handlers()
179
180
181 Development
182 ===========
183
184 Use `make` to run the unit tests::
185
186 make test
187
188 `pytest` is used to run unit tests internally.
189
190 A `tox` target is provided to run tests using all installed and supported Python versions::
191
192 make tox
193
194 `jsonpickle` itself has no dependencies beyond the Python stdlib.
195 `tox` is required for testing when using the `tox` test runner only.
196
197 The testing requirements are specified in `setup.cfg`.
198 It is recommended to create a virtualenv and run tests from within the
199 virtualenv.::
200
201 python3 -mvenv env3
202 source env3/bin/activate
203 pip install --editable '.[dev]'
204 make test
205
206 You can also use a tool such as `vx <https://github.com/davvid/vx/>`_
207 to activate the virtualenv without polluting your shell environment::
208
209 python3 -mvenv env3
210 vx env3 pip install --editable '.[dev]'
211 vx env3 make test
212
213 If you can't use a venv, you can install the testing packages as follows::
214
215 pip install .[testing]
216
217 `jsonpickle` supports multiple Python versions, so using a combination of
218 multiple virtualenvs and `tox` is useful in order to catch compatibility
219 issues when developing.
220
221 GPG Signing
222 ===========
223
224 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.
225
226 License
227 =======
228
229 Licensed under the BSD License. See COPYING for details.