Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
py_ubjson.egg-info/ | H | 03-May-2022 | - | 117 | 91 | |
src/ | H | 18-Apr-2020 | - | 2,791 | 1,992 | |
test/ | H | 18-Apr-2020 | - | 739 | 523 | |
ubjson/ | H | 18-Apr-2020 | - | 997 | 683 | |
CHANGELOG | H A D | 18-Apr-2020 | 2 KiB | 61 | 49 | |
LICENSE | H A D | 08-Sep-2018 | 11.1 KiB | 202 | 169 | |
MANIFEST.in | H A D | 08-Sep-2018 | 106 | 4 | 3 | |
NOTICE | H A D | 30-Nov-2019 | 341 | 15 | 10 | |
PKG-INFO | H A D | 18-Apr-2020 | 4.7 KiB | 117 | 91 | |
README.md | H A D | 30-Nov-2019 | 2.9 KiB | 87 | 62 | |
UBJSON-Specification.md | H A D | 08-Sep-2018 | 12.4 KiB | 377 | 314 | |
ez_setup.py | H A D | 08-Sep-2018 | 11.8 KiB | 416 | 315 | |
setup.cfg | H A D | 18-Apr-2020 | 38 | 5 | 3 | |
setup.py | H A D | 18-Apr-2020 | 4.2 KiB | 120 | 85 |
README.md
1# Overview 2 3This is a Python v3.2+ (and 2.7+) [Universal Binary JSON](http://ubjson.org) encoder/decoder based on the [draft-12](UBJSON-Specification.md) specification. 4 5 6# Installing / packaging 7```shell 8# To get from PyPI 9pip3 install py-ubjson 10 11# To only build extension modules inline (e.g. in repository) 12python3 setup.py build_ext -i 13 14# To build & install globally 15python3 setup.py install 16 17# To skip building of extensions when installing (or building) 18PYUBJSON_NO_EXTENSION=1 python3 setup.py install 19``` 20**Notes** 21 22- The extension module is not required but provide a significant speed boost. 23- The above can also be run with v2.7+ 24- This module is also available via [Anaconda (conda-forge)](https://anaconda.org/conda-forge/py-ubjson) 25- PyPI releases are signed with the [Iotic Labs Software release signing key](https://developer.iotic-labs.com/iotic-labs.com.asc) 26- At run time, one can check whether compiled version is in use via the _ubjson.EXTENSION_ENABLED_ boolean 27 28 29# Usage 30It's meant to behave very much like Python's built-in [JSON module](https://docs.python.org/3/library/json.html), e.g.: 31```python 32import ubjson 33 34encoded = ubjson.dumpb({u'a': 1}) 35 36decoded = ubjson.loadb(encoded) 37``` 38**Note**: Only unicode strings in Python 2 will be encoded as strings, plain *str* will be encoded as a byte array. 39 40 41# Documentation 42```python 43import ubsjon 44help(ubjson.dump) 45help(ubjson.load) 46``` 47 48# Command-line utility 49This converts between JSON and UBJSON formats: 50```shell 51python3 -mubjson 52USAGE: ubjson (fromjson|tojson) (INFILE|-) [OUTFILE] 53``` 54 55 56# Tests 57 58## Static 59This library has been checked using [flake8](https://pypi.python.org/pypi/flake8) and [pylint](http://www.pylint.org), using a modified configuration - see _pylint.rc_ and _flake8.cfg_. 60 61## Unit 62```shell 63python3 -mvenv py 64. py/bin/activate 65pip install -U pip setuptools 66pip install -e .[dev] 67 68./coverage_test.sh 69``` 70**Note**: See `coverage_test.sh` for additional requirements. 71 72 73# Limitations 74- The **No-Op** type is only supported by the decoder. (This should arguably be a protocol-level rather than serialisation-level option.) Specifically, it is **only** allowed to occur at the start or between elements of a container and **only** inside un-typed containers. (In a typed container it is impossible to tell the difference between an encoded element and a No-Op.) 75- Strongly-typed containers are only supported by the decoder (apart from for **bytes**/**bytearray**) and not for No-Op. 76- Encoder/decoder extensions are not supported at this time. 77 78 79# Why? 80The only existing implementation I was aware of at the time of writing ([simpleubjson](https://github.com/brainwater/simpleubjson)) had the following limitations: 81 82- Does not support efficient binary encoding 83- Only supports draft-9 84- Only supports individual Python types rather than anything implementing an interface (e.g. _Mapping_) 85- Does not decode nested arrays or objects in expected form 86- Lacks C extension speed-up 87