Package: bjdata
Binary JData for Python - a lightweight binary JSON formatCopyright: (C) Qianqian Fang (2020-2023) <q.fang at neu.edu>Copyright: (C) Iotic Labs Ltd. (2016-2019) <vilnis.termanis at iotic-labs.com>License: Apache License, Version 2.0Version: 0.4.1URL:https://pypi.org/project/bjdata/Github:https://github.com/NeuroJSON/pybjBJData Spec Version:V1 Draft 2Acknowledgement: This project is supported by US National Institute of Health (NIH) grant U24-NS124027This is a Python v3.2+ (and 2.7+)Binary JDataencoder
and decoder based on theDraft-2specification.Installing / packaging## To get from PyPIpip3installbjdataOther instalation options## Installing / packaging## To get from PyPI without root/administrator privilegepip3installbjdata--user## To get from PyPI via pythonpython3-mpipinstallbjdata## To only build extension modules in-place (e.g. in repository)python3setup.pybuild_ext-i## To build & install globallypython3setup.pyinstall## To skip building of extensions when installing (or building)PYBJDATA_NO_EXTENSION=1python3setup.pyinstallThis package can be directly installed on Debian Bullseye/Ubuntu 21.04 or newer viasudo apt-get install python3-bjdataBothpython-bjdata(for Python 2.7+) andpython3-bjdata(for Python 3.x) can
also be installed on Ubuntu viasudo add-apt-repository ppa:fangq/ppa
sudo apt-get update
sudo apt-get install python-bjdata python3-bjdataNotesThe extension module is not required but provide a significant speed boost.The above can also be run with v2.7+ (replacingpip3andpython3above bypipandpython, respectively)At run time, one can check whether compiled version is in use via thebjdata.EXTENSION_ENABLEDbooleanUsageIt's meant to behave very much like Python's built-inJSON module, e.g.:importbjdataasbjobj={'a':123,'b':12.3,'c':[1,2,3,[4,5],'test']}encoded=bj.dumpb(obj)decoded=bj.loadb(encoded)Note: Only unicode strings in Python 2 will be encoded as strings, plainstrwill be encoded as a byte array.Documentationimportbjdataasbjhelp(bj.dump)help(bj.load)help(bj.encoder.dump)help(bj.decoder.load)Command-line utilityThis converts between JSON and BJData formats:python3-mbjdata
USAGE:bjdata(fromjson|tojson)(INFILE|-)[OUTFILE]EXAMPLES:

python3-mbjdatafromjsoninput.jsonoutput.bjd
python3-mbjdatatojsoninput.bjdoutput.jsonTestsStaticThis library has been checked usingflake8andpylint, using a modified configuration -
seepylint.rcandflake8.cfg.Unitpython3-mvenvpy
.py/bin/activate
pipinstall-Upipsetuptools
pipinstall-e.[dev]./coverage_test.shNote: Seecoverage_test.shfor additional requirements.LimitationsTheNo-Optype is only supported by the decoder. (This should arguably be
a protocol-level rather than serialisation-level option.) Specifically, it isonlyallowed to occur at the start or between elements of a container andonlyinside un-typed containers. (In a typed container it is impossible to
tell the difference between an encoded element and a No-Op.)Strongly-typed containers are only supported by the decoder (apart from forbytes/bytearray) and not for No-Op.Encoder/decoder extensions are not supported at this time.Encoder/decoder only support numpy NDarrays and scalars, other numpy types are not supported.AcknowledgementThis package was modified based on the py-ubjson package developed byIotic Labs Ltd.Project URL:https://github.com/Iotic-Labs/py-ubjsonThe major changes were focused on supporting the Binary JData SpecificationDraft 2-
an extended Universal Binary JSON (UBJSON) Specification Draft-12 by adding
the below new features:BJData adds 4 new numeric data types:uint16 [u],uint32 [m],uint64 [M]andfloat16 [h]BJData supports an optimized ND array containerBJData does not convert NaN/Inf/-Inf tonullBJData uses little-Endian as the default integer/floating-point numbers while UBJSON uses big-EndianBJData only permits non-zero-fixed-length data types (UiuImlMLhdDC) in strongly-typed array/object containers