Skip to main content

Simple universal binary json decoder/encoder for Python.

Project description

Simple UBJSON in Python

`UBJSON`_ is the universally compatible format specification for binary `JSON`_.
It's pretty and simple data format and `simpleubjson`_ aims to be also the same.

.. code-block:: python

>>> import simpleubjson
>>> ubjdata = simpleubjson.encode({'hello': 'world', 'тест': [1, 2, 3]})
>>> ubjdata

:func:`simpleubjson.encode` function transforms Python objects into UBJSON
`binary` string data. To decode it back to Python objects use
:func:`simpleubjson.decode` function:

.. code-block:: python

>>> simpleubjson.decode(ubjdata)
{'hello': 'world', 'тест': [1, 2, 3]}

Moreover, you may also introspect UBJSON data via :func:`simpleubjson.pprint`

.. code-block:: python

>>> simpleubjson.pprint(ubjdata)
[S] [i] [5] [hello]
[S] [i] [5] [world]
[S] [i] [8] [тест]
[i] [1]
[i] [2]
[i] [3]

This representation is a bit more human friendly than traditional hexview and
designed specially for UBJSON format.

Currently `simpleubjson` follows Draft-9 specification by default, but you
may change specification version by passing ``spec="draft-N"`` argument for
:func:`~simpleubjson.decode`, :func:`~simpleubjson.encode` and
:func:`~simpleubjson.pprint` functions.

.. _JSON:
.. _simpleubjson:


0.7.0 (2014-06-21)

- Add support of UINT8 type for Draft-9 spec;
- Add support of CHAR type for Draft-9 spec;
- Optimize strings encoding with new types;
- Switch to BSD 2 clause license;

0.6.1 (2013-04-29)

- Fix compatibility with Python 3.x;
- Force binary strings have utf-8 charset on encoding;
- Improve UBJSON decoding performance;

0.6.0 (2013-04-10)

- Project refactoring and code cleanup;
- Raise overall performance for 100-400% times depending on test case;
- Update Draft-9 support to RC state: handle new containers markers;

0.5.0 (2012-07-07)

- Fix encoding of unsized objects;
- Fix pprinting containers with NoOp markers;
- Fix markers of integers values for Draft-9 spec;

0.4.0 (2012-06-29)

- Encode `set` and `frozenset` types;
- Experimental implementation of Draft-9 specification;
- Fix encoding of `dict` iterators;
- Support Python 3.x;

0.3.0 (2012-03-03)

- Add `simpleubjson.pprint` function to dump UBJSON data using ``[ ]``-notation;
- Allow decode standalone NoOp values;
- Encode `inf` and `-inf` values as `null`;
- Remove support of custom markers and handlers;
- Wrap `HUGE` values with `Decimal` class and encode `Decimal` instances back
to `HUGE`;

0.2.0 (2011-11-30)

- Allow decoder produce NoOp values;
- Allow to specify custom decoding/encoding handlers;
- Fix float/double values handling;

0.1.0 (2011-10-13)

- First version with support Draft-8 specification.

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 simpleubjson, version 0.7.0
Filename, size File type Python version Upload date Hashes
Filename, size simpleubjson-0.7.0.tar.gz (30.6 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