json_np
Json for numpy, or if you prefer, json no problems!
Authors: Luca de Alfaro (luca@dealfaro.com) and Massimo Di Pierro (mdipierro@gmail.com)
This is a version of Json that can handle also:
- Dates
- Sets
- numpy array
- bytes
There are two ways to use it.
Basic Usage
import json_np
import numpy as np
a = np.array([3, 4, 5])
s = json_np.dumps(a)
aa = json_np.loads(s)
Here, we have applied json_np.dumps to a numpy array, but we could equally
well have used a datetime, a dictionary, a list, etc (nesting of such types is
allowed).
Class-Based Usage
You can also dump any object.
All object attributes, except those whose name begins with underscore (_),
will be serialized.
Optionally, if serializable_only is True, only objects that are
instances of Serializable, or that are dates, numpy arrays, will be
serialized.
The deserialization happens in the same class, if:
- the class can be loaded
- the class initializer has no required arguments.
If any of these two conditions is not met, the deserialization happens
using the Serializable class.
from json_np import Serializable
class C(object):
def __init__(self, a=8):
super().__init__()
self.a = a # Serialized
self._b = 32 # Not serialized
c = C("hello")
s = json_np.dumps(c)
cc = json_np.loads(s)
Obviously, you should ensure that C contains compatible fields when it is deserialized, in case the code changed in the meantime.
History
This package was originally developed by Luca and Massimo at Camio, for Python2. The work was open sourced. The package was later ported to Python 3. The authors thank Camio for allowing the open-sourcing of the code.
Metadata
Release files for json-np 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| json_np-0.0.6.tar.gz | 5.5 kB | Without provenance | Details for json_np-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json_np-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for json_np-0.0.6-py3-none-any.whl |
Total release size: 12.0 kB
Release files / json_np-0.0.6.tar.gz
| Download URL | json_np-0.0.6.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57729862ec4587ce47fbbda135996e0b4f1da4abd95a90b916c6536d41f3e7f4
|
|
BLAKE2b-256 checksum How to use checksums |
ff8543aecfef9ff54e6d015956b679b1d3868147c03564325f0df467ec71a9b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.11
|
Release files / json_np-0.0.6-py3-none-any.whl
| Download URL | json_np-0.0.6-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4df28b89684fc81abc36803681ae44fa6ee34ae26049400686d0d69243f88fe
|
|
BLAKE2b-256 checksum How to use checksums |
651cebe40e7b3b5a1e5429dafe83d1b2a7cc9a3b59cc09390f87381774095c57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.11
|
Security for json-np 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.