Skip to main content

Dumps and loads numpy-arrays into or from json

Project description

TestStatus PyPiStatus BlackStyle BlackPackStyle MITLicenseBadge

Transparent dumps and loads of numpy-arrays. If a list is loaded from a json string it is given to numpy.array(). If further, the resulting array has a primitive type of either (int, float) it is returned by loads.

install

pip install json-numpy-sebastian-achim-mueller

Encoder

to dump with json.dumps().

object_hook

to load with json.loads().

example

import numpy
import json_numpy

obj = json_numpy.loads(s='{"a": [1.0, NaN]}')
assert isinstance(obj["a"], numpy.ndarray)

json_numpy.dumps(obj)
'{"a": [1.0, NaN]}'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page