Skip to main content

JData for Python - a lightweight and portable data annotation method

Build Status

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

This package can also be installed on Ubuntu 21.04 or Debian Bullseye via

sudo apt-get install python3-jdata

On older Ubuntu or Debian releases, you may install jdata via the below PPA:

sudo add-apt-repository ppa:fangq/ppa
sudo apt-get update
sudo apt-get install python3-jdata

Dependencies:

  • bjdata: PIP: run pip install bjdata see https://pypi.org/project/bjdata/
  • numpy: PIP: run pip install numpy or sudo apt-get install python-numpy
  • backports.lzma: PIP: run sudo apt-get install liblzma-dev and pip install backports.lzma (needed for Python 2.7)

Replacing pip by pip3 if you are using Python 3.x. If either pip or pip3 does not exist on your system, please run

    sudo apt-get install python3-pip

Please note that in some OS releases (such as Ubuntu 20.04), python2.x and python-pip are no longer supported.

One can also install this module from the source code. To do this, you first check out a copy of the latest code from Github by

    git clone https://github.com/fangq/pyjdata.git
    cd pyjdata

then install the module to your local user folder by

    python3 setup.py install --user

or, if you prefer, install to the system folder for all users by

    sudo python3 setup.py install

Please replace python by python3 if you want to install it for Python 3.x instead of 2.x.

Instead of installing the module, you can also import the jdata module directly from your local copy by cd the root folder of the unzipped pyjdata package, and run

   import jdata as jd

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

To see additional data type support, please run the built-in test using below command

python3 -m unittest discover -v test

Metadata

Release files for jdata 0.3.7

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

Source distribution (sdist)

Source distribution for jdata 0.3.7
File Size Uploaded
jdata-0.3.7.tar.gz 13.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jdata 0.3.7
File Interpreter ABI Platform
jdata-0.3.7-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 25.7 kB

Release files / jdata-0.3.7.tar.gz

Download URL jdata-0.3.7.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6dae222653cbbad03cbffb44e9354d077884380385185685365f0a7defff7173
BLAKE2b-256 checksum
How to use checksums
1db7e375b9801861179be253ac0747b6b6ebab0927e97c8c63c60c8482c080ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Release files / jdata-0.3.7-py2.py3-none-any.whl

Download URL jdata-0.3.7-py2.py3-none-any.whl
Size 12.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e4d9d59d696f987f0b3a3177ecd9aeb4fd45583f0c0e13b60cc4d24a6072bef1
BLAKE2b-256 checksum
How to use checksums
e17e5e7d8319f90a621af2efa2defa4cc52426625f15b2e3411efb0415973900
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Release history Release notifications | RSS feed

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

This release

0.3.7 This release

2 release files

0.3.6

1 release file

0.3.5

1 release file

0.3.0

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2

1 release file

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