Skip to main content

Encoding and decoding Python data structrues using portable JData-annotated formats

Project description

# JData for Python - a lightweight and portable data annotation method

The [JData Specification]( defines a lightweight language-independent data annotation interface targetted at storing and sharing complex data structures across different programming languages such as MATLAB, JavaScript, Python etc. Using JData formats, a complex Python data structure can be encoded as a dict object that is easily serialized as a JSON/binary JSON file and share such data between programs of different languages.

## How to use

The PyJData module is easy to use. You can use the encode()/decode() functions to encode Python data into JData annotation format, or decode JData structures into native Python data, for example

` import jdata as jd import numpy as np a={'str':'test','num':1.2,'list':[1.1,[2.1]],'nan':float('nan'),'np':np.arange(1,5,dtype=np.uint8)} jd.encode(a) jd.decode(jd.encode(a)) d1=jd.encode(a,{'compression':'zlib','base64':1}) d1 jd.decode(d1,{'base64':1}) `

One can further save the JData annotated data into JSON or binary JSON (UBJSON) files using the function, or loading JData-formatted data to Python using jdata.load

` import jdata as jd import numpy as np a={'str':'test','num':1.2,'list':[1.1,[2.1]],'nan':float('nan'),'np':np.arange(1,5,dtype=np.uint8)},'test.json') newdata=jd.load('test.json') newdata `

Project details

Download files

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

Files for jdata, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size jdata-0.2.1.tar.gz (6.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page