JData for Python - a lightweight and portable data annotation method
- Copyright: (C) Qianqian Fang (2019) <q.fang at neu.edu>
- License: Apache License, Version 2.0
- Version: 0.2
- URL: https://github.com/fangq/pyjdata
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 install
- Github: download from https://github.com/fangq/pyjdata
- PIP: run
pip install jdatasee https://pypi.org/project/jdata/
Optional Dependency (if reading or writing Binary JData/UBJSON files):
- bjdata: PIP: run
pip install bjdatasee https://pypi.org/project/bjdata/ - numpy: PIP: run
pip install numpyorsudo apt-get install python-numpy
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 jdata.save 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)}
jd.save(a,'test.json')
newdata=jd.load('test.json')
newdata
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file jdata-0.3.0.tar.gz.
File metadata
- Download URL: jdata-0.3.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
786b31c6316d54007799e83713776d09b983722d3cb68e8d44e0ce8bdb2b36eb
|
|
| MD5 |
1ca2a6132c4640dc5c8ff96fa6ca74e5
|
|
| BLAKE2b-256 |
a08eb59b1fbb6eb8a5352d4d939a0ba36dcc7aa27d7d4dcdff43754a2b595008
|