Extendable json encode/decode library.
Project description
Welcome to superjson Documentation
Features:
Support for date, datetime, set, OrderedDict, deque, numpy.ndarray, that the original json module can not serialize.
Easy to extend to support any custom data type, see how.
Allow // double slash started comments, # Pound key started comments style comment in json file (Good for human/machine readable config file).
Use .gz for file extension, data will be automatically compressed.
Atomic Write is ensured.
Usage:
>>> from collections import OrderedDict, deque
>>> from datetime import date, datetime
>>> from superjson import json
>>> import numpy as np
>>> data = {
... "int": 1,
... "str": "Hello",
... "bytes": "Hello".encode("utf-8"),
... "date": date(2010, 1, 1),
... "datetime": datetime(2020, 1, 1, 18, 30, 0, 500),
... "set": set([
... datetime(2000, 1, 1),
... datetime(2000, 1, 2),
... ]),
... "deque": deque([
... deque([1, 2]),
... deque([3, 4]),
... ]),
... "ordereddict": OrderedDict([
... ("b", OrderedDict([("b", 1), ("a", 2)])),
... ("a", OrderedDict([("b", 1), ("a", 2)])),
... ]),
... "array": np.array([
... [1, 2],
... [1.1, 2.2],
... ["a", "b"],
... [datetime.now(), datetime.now()],
... ]),
... }
>>> json.dumps(data, pretty=True)
...
>>> json.dump(data, "data.gz", overwrite=True) # atomic write ensured
...
Quick Links
Install
superjson is released on PyPI, so all you need is:
$ pip install superjson
To upgrade to latest version:
$ pip install --upgrade superjson
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
superjson-0.0.10.tar.gz
(439.6 kB
view hashes)
Built Distribution
superjson-0.0.10-py2-none-any.whl
(552.8 kB
view hashes)
Close
Hashes for superjson-0.0.10-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f303449557f35abe6760c57a949eb7a65d109337eb1134587c2420495c48fd2d |
|
MD5 | 94f8147ed06511c27be9d05317028f4a |
|
BLAKE2b-256 | 0ea313ce5792d0e7393487de1a0daa94f2dfe3d54f3093f800b32dd5320c08dd |