Registry / serialization / json-numpy

json-numpy

JSON →
library2.1.1pypypi✓ verified 85d ago

A library for encoding and decoding NumPy arrays and scalars to/from JSON-compatible formats. Current version 2.1.1, compatible with Python >=3.8. Maintained actively.

pip install json-numpy
INSTALL
IMPORT
SIG · JSON-NUMPY
J
json-numpy
serializationpythonv2.1.1
Install
3.6s avg
Import
249ms
Disk
89MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.252s · 89.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.6s · import 0.246s · 86MB
89MB installed
● package 89MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

json_numpy
import json_numpy
Direct import of the module for conversion functions.

Basic usage: encode NumPy array to JSON string and decode back.

import json_numpy import numpy as np arr = np.array([1, 2, 3]) encoded = json_numpy.dumps(arr) print(encoded) decoded = json_numpy.loads(encoded) print(decoded)
Debug
Known issues
gotchajson_numpy.dumps does not encode Infinity or NaN by default; they become null. To preserve them, pass allow_nan=True.
fix
Use json_numpy.dumps(obj, allow_nan=True).
affects: all
gotchaDeserialization returns numpy arrays by default. To get Python lists, convert manually.
fix
Use json_numpy.loads(s, as_list=True) or explicit list() after decode.
affects: all
Errors
Common errors & fixes
AttributeError: module 'json_numpy' has no attribute 'dumps'
Incorrect import assuming dumps/loads are top-level; they are inside json_numpy module.
fix
Use json_numpy.dumps() and json_numpy.loads() after importing json_numpy.
TypeError: Object of type ndarray is not JSON serializable
Using standard json.dumps directly on numpy arrays.
fix
Use json_numpy.dumps(arr) instead of json.dumps(arr).
Upgrade
Version history
2.1.1latest on PyPI · released Jun 30, 2025
Audit
Dependencies
numpyrequiredCore dependency for array handling
Agent activity
8 hits · last 30 days
node
8
Resources
json-numpy — pip install json-numpy · libregistry