Skip to main content

nujson: The UltraJSON Fork That Supports Numpy Serialization That Actually Includes Python Wheels

Inspired by Pandas' ujson

Build Status Version Status

How to install

Python versions: Python 3.5+

Using pip:

pip install shaped-nujson

If you get an error like this:

ERROR: Could not find a version that satisfies the requirement numpy>=1.16.4 (from nujson) (from versions: 1.9.3)
ERROR: No matching distribution found for numpy>=1.16.4 (from nujson)

Try this:

pip uninstall numpy
pip install numpy==1.16.4
pip install shaped-nujson

Example

>>> import numpy as np
>>> import nujson as ujson
>>> a = {"a": np.int64(100)}
>>> ujson.dumps(a)
'{"a":100}'
>>> a["b"] = np.float64(10.9)
>>> ujson.dumps(a)
'{"a":100,"b":10.9}'
>>> a["c"] = np.str_("12")
>>> ujson.dumps(a)
'{"a":100,"b":10.9,"c":"12"}'
>>> a["d"] = np.array(list(range(10)))
>>> ujson.dumps(a)
'{"a":100,"b":10.9,"c":"12","d":[0,1,2,3,4,5,6,7,8,9]}'
>>> a["e"] = np.repeat(3.9, 4)
>>> ujson.dumps(a)
'{"a":100,"b":10.9,"c":"12","d":[0,1,2,3,4,5,6,7,8,9],"e":[3.9,3.9,3.9,3.9]}'

Why make such a package and what is modified?

On Python 3, some data types of NumPy are not serializable. Here are some references:

One solution is type conversion like: int(numpy.int64) and numpy.array.tolist(). But it's not good for performance. After searching the Internet, we found an unmaintained project Komnomnomnom/ultrajson which recommends to use Pandas' ujson.

We tried but found Pandas is too heavy for our projects. So we decided to build our own lightweight fork. Currently, esn's ujson master branch has some problems we needed to solve, and the master branch is based on the the v1.35 ujson.

The main point is to convert NumPy data types in C, with calling NumPy's header. Commit 187bd15 has the most changes we made to support NumPy, and commit afedc42 fixes a build issue on macOS caused by Clang.

Metadata

Release files for shaped-nujson 1.35.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shaped-nujson 1.35.2
File Size Uploaded
shaped-nujson-1.35.2.tar.gz 186.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for shaped-nujson 1.35.2
File
shaped_nujson-1.35.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
shaped_nujson-1.35.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
shaped_nujson-1.35.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
shaped_nujson-1.35.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details

Total release size: 500.4 kB

Release files / shaped-nujson-1.35.2.tar.gz

Download URL shaped-nujson-1.35.2.tar.gz
Size 186.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1b0af07484ccdd5ac0045bb3d5c9e3a04d05171defa4d7e02f80b03e07031a6a
BLAKE2b-256 checksum
How to use checksums
aceb3304e6652c187fb4c27843b348d03ac01c72dfd12e93aa67db274f3c3933
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Release files / shaped_nujson-1.35.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL shaped_nujson-1.35.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 79.5 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
88e5bcd755fda68f75f569e554635167f16074ce6288390fe0b81a6b28f30d14
BLAKE2b-256 checksum
How to use checksums
4bf27fe8adc18f2ac14053914246453e213bc3f6022a6bb0df16d9a81eac8460
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Release files / shaped_nujson-1.35.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL shaped_nujson-1.35.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 80.2 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
666c75377df51879c7c27d9ff981a47fd6500bc44783340a88d1440dd1fb41da
BLAKE2b-256 checksum
How to use checksums
dc6c66298196b0afa18fb48209fe20c3866168296bd31760496ef73ab1172755
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Release files / shaped_nujson-1.35.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL shaped_nujson-1.35.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 77.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
107a1e2ec30ffd0671ef4f9f51bde3e572955996e57001c7650a8a425117f93b
BLAKE2b-256 checksum
How to use checksums
ba6127381396aee374a712d3a9f5fd81dd1ec94cb007966bae5559d2f071026c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Release files / shaped_nujson-1.35.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL shaped_nujson-1.35.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 76.9 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ac01d603b51e24cb08654f32038f9bdc46ff420731927b6cef5806611379c448
BLAKE2b-256 checksum
How to use checksums
334703c99c5b6814ae393a84d7bdbdc628a0a18b28f0005621b2f2d671177eaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Release history Release notifications | RSS feed

This release

1.35.2 This release

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page