This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A simple way of 'extending' json to support additional types like datetime, Decimal and binary data.

Project Description
  • Free software: Simplified BSD license


Jsonte is just a simple and well defined way of ‘extending’ json to support some additional types.

The primary goal is to add support for data types that are commonly used in databases. In particular:

  • dates, times, and timestamps (both with and without timezones)
  • arbitrary precision numeric entries
  • binary data

A secondary goal was to do this in such a way that the resulting json was easily human readable, and also programming language agnostic.

The format is simple, and is always itself valid json.

* A date:      { "#date": "2015-05-28" }
* A time:      { "#time": "22:12:42.381000" }
* A timestamp: { "#tstamp": "2015-05-28T22:13:42.381000" }

These are just the ISO formats for each of the above items.

* A numeric entry:  { "#num": "1234.0000" }
* Some binary data: { "#bin": "SGVsbG8gV29ybGQhAA==" }

The numeric entry is encoded as a string so the degree of precision is not lost. The binary data is just base64 encoded.

Key Escaping

Keys in objects that start with either a hash (#) or a tidle (~) are escaped by a tidle (~) being prefixed to the key. This is to avoid any accidental collisions with the ‘special’ object keys used.

So an object that would normaly be encoded as { “#bin”: 1234 } would become { “~#bin”: 1234 } when encoded by jsonte, and { “~foo”: “bar” } would become { “~~foo”: “bar” }

Python Implementation

The python implementation is designed to be a drop-in replacement for the standard json library, and is tested on Python 2.6, 2.7 and 3.3+.

import datetime
import decimal
import jsonte

timezone ='Australia/Victoria')
data = { 'now':,
         'cost': decimal.Decimal('12.50'),
         'binary': bytearray('Hello World!\x00\x01\x02'),
         '%foo': 'a',
         '#num': 1,
         '~baz': 2.0 }

serialiser = jsonte.JsonteSerialiser(indent=4, sort_keys=True)
s = serialiser.dumps(data)
data2 = serialiser.loads(s)

At this point we have

>>> data is data2
>>> data == data2
>>> print s
    "%foo": "a",
    "binary": {
        "#bin": "SGVsbG8gV29ybGQhAAEC"
    "cost": {
        "#num": "12.50"
    "now": {
        "#tstamp": "2015-05-28T23:43:40.454000"
    "now_with_tz": {
        "#tstamp": "2015-05-28T23:43:40.454000+10:00"
    "the_time": {
        "#time": "23:43:40.454000"
    "today": {
        "#date": "2015-05-28"
    "~#num": 1,
    "~~baz": 2.0


0.8.6 (2016-04-13)

  • Update README, and tox.ini to indicate Python 3.5 support.

0.8.5 (2015-08-09)

  • Bugfix: fix an issue when _one_shot was used in iterencode in non-2.6 versions of Python

0.8.4 (2015-08-06)

  • Major reworking
    • Make jsonte a module rather than a package, since the scope is small enough to do so.
    • Remove top level functions and put the core functionality into a class that is instantiated.
    • Allow a custom objecthook to be used.
    • Allow the ability to enforce json ‘websafety’ through raising an exception or prefixing the string.
    • Allow additional type serialisers to be added in any order (subclasses no longer need to go first).
    • Support for Python 2.6, 3.3 and 3.4 (as initially just 2.7)

0.8.3 (2015-06-08)

  • Base SerialisationDict on a separate a mixim class to provide more flexability.

0.8.2 (2015-06-04)

  • Rename JsonteDict to SerialisationDict to add clarity.
  • Give access to the registered type classes.

0.8.0 (2015-05-22)

  • Initial version
Release History

Release History

This version
History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
jsonte-0.8.6.tar.gz (8.8 kB) Copy SHA256 Checksum SHA256 Source Apr 13, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting