Python wrapper around rapidjson
Clone or download
lelit Check for --rj-include-dir earlier
This targets issue #110, and fixups commit c4df408:
I'm quite surprised that this went unnoticed when I closed issue #60... sorry.
Latest commit d10ab02 Aug 2, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmarks Renew the benchmarks tables Jul 23, 2018
docs Raise correct exception in `Encoder` code sample Aug 1, 2018
rapidjson @ 67a17cf Track rapidjson@67a17cf for bugfixes Jun 2, 2018
tests Add failing tests for additionalProperties and patternProperties Jun 2, 2018
.appveyor.yml Use cibuildwheel 0.9.3 Jul 10, 2018
.dir-locals.el Avoid error when whitespace.el is not loaded Nov 11, 2017
.gitignore Ignore pytest cache directory Mar 25, 2018
.gitlab-ci.yml Use cibuildwheel 0.9.3 Jul 10, 2018
.gitmodules Point rapidjson submodule to Dec 14, 2017
.travis.yml Use cibuildwheel 0.9.3 Jul 10, 2018
CHANGES.rst Release 0.6.3 Jul 10, 2018
LICENSE Add explicit license, authorship and copyright holders to most sources Aug 23, 2017 Hide AppVeyor configuration, to be on par with Travis Apr 25, 2018
Makefile Renew the benchmarks tables Jul 23, 2018
Makefile.release New tiny-release target Dec 21, 2017
Makefile.virtualenv Fix virtualenv creation for Python < 3.6 Sep 10, 2017
README.rst Cosmetic, now the docinfo table should be properly rendered by Warehouse Jul 23, 2018
rapidjson.cpp Fix validation_error refcount, PyModule_AddObject() steals a reference Jun 8, 2018
requirements-test.txt Fixup 82e4fbf, tests require Sphinx Jul 23, 2018
requirements.txt Fixup 82e4fbf, tests require Sphinx Jul 23, 2018
setup.cfg Replace pytest's deprecated section name Aug 31, 2016 Check for --rj-include-dir earlier Aug 2, 2018
tox.ini Extend copyright years Jan 7, 2018
version.txt Release 0.6.3 Jul 10, 2018



Python wrapper around RapidJSON

Authors: Ken Robbins <>
Lele Gaifax <>
License:MIT License
Status: Build status Documentation status

RapidJSON is an extremely fast C++ JSON parser and serialization library: this module wraps it into a Python 3 extension, exposing its serialization/deserialization (to/from either bytes, str or file-like instances) and JSON Schema validation capabilities.

Latest version documentation is automatically rendered by Read the Docs.

Getting Started

First install python-rapidjson:

$ pip install python-rapidjson

or, if you prefer Conda:

$ conda install -c conda-forge python-rapidjson

Basic usage looks like this:

>>> import rapidjson
>>> data = {'foo': 100, 'bar': 'baz'}
>>> rapidjson.dumps(data)
>>> rapidjson.loads('{"bar":"baz","foo":100}')
{'bar': 'baz', 'foo': 100}
>>> class Stream:
...   def write(self, data):
...      print("Chunk:", data)
>>> rapidjson.dump(data, Stream(), chunk_size=5)
Chunk: b'{"foo'
Chunk: b'":100'
Chunk: b',"bar'
Chunk: b'":"ba'
Chunk: b'z"}'


If you want to install the development version (maybe to contribute fixes or enhancements) you may clone the repository:

$ git clone --recursive


The --recursive option is needed because we use a submodule to include RapidJSON sources. Alternatively you can do a plain clone immediately followed by a git submodule update --init.

Alternatively, if you already have (a compatible version of) RapidJSON includes around, you can compile the module specifying their location with the option --rj-include-dir, for example:

$ python3 build --rj-include-dir=/usr/include/rapidjson

A set of makefiles implement most common operations, such as build, check and release; see make help output for a list of available targets.


python-rapidjson tries to be as performant as possible while staying compatible with the json module.

See the this section in the documentation for a comparison with other JSON libraries.


Here are things in the standard json library supports that we have decided not to support:

separators argument
This is mostly used for pretty printing and not supported by RapidJSON so it isn't a high priority. We do support indent kwarg that would get you nice looking JSON anyways.
Coercing keys when dumping
json will stringify a True dictionary key as "true" if you dump it out but when you load it back in it'll still be a string. We want the dump and load to return the exact same objects so we have decided not to do this coercion.
Arbitrary encodings
json.loads() accepts an encoding kwarg determining the encoding of its input, when that is a bytes or bytearray instance. Although RapidJSON is able to cope with several different encodings, we currently support only the recommended one, UTF-8.