Python wrapper around rapidjson
Project description
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)
'{"bar":"baz","foo":100}'
>>> 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"}'
Development
If you want to install the development version (maybe to contribute fixes or enhancements) you may clone the repository:
$ git clone --recursive https://github.com/python-rapidjson/python-rapidjson.git
A set of makefiles implement most common operations, such as build, check and release; see make help output for a list of available targets.
Performance
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.
Incompatibility
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.
Changes
0.9.1 (2019-11-13)
Fix memory leak in case of failed validation (issue 126)
0.9.0 (2019-11-13)
Produce Python 3.8 wheels
Compatibility fix for Python 3.8 (issue #125)
New dump option write_mode, supporting RapidJSON’s kFormatSingleLineArray option (issue #123), thanks to Nguyễn Hồng Quân for the initial implementation (PR #124)
0.8.0 (2019-08-09)
New serialization option bytes_mode to control how bytes instances gets encoded (issue #122)
0.7.2 (2019-06-09)
Hopefully fix the memory leak when loading from a stream (issue #117)
0.7.1 (2019-05-11)
Raise a more specific exception on loading errors, JSONDecodeError, instead of generic ValueError (issue #118)
Fix optimization path when using OrderedDicts (issue #119)
Fix serialization of IntEnums (issue #121)
I spent quite a lot of time investigating on the memory leak when loading from a stream (issue #117): as I was not able to fully replicate the problem, I cannot be sure I solved the problem… sorry!
0.7.0 (2019-02-11)
Raise correct exception in code samples (PR #109), thanks to Thomas Dähling
Fix compilation with system-wide install of rapidjson (issue #110)
Use current master version of rapidjson, that includes a fix for its issue #1368 and issue #1336, and cures several compilation warnings as well (issue #112 and issue #107)
Fix memory leak when using object_hook (issue #115)
0.6.3 (2018-07-11)
No visible changes, but now PyPI carries binary wheels for Python 3.7.
0.6.2 (2018-06-08)
Use a more specific ValidationError, to differentiate from invalid JSON
0.6.1 (2018-06-06)
Nothing new, attempt to build Python 3.6 binary wheels on Travis CI
0.6.0 (2018-06-06)
Add a new comparison table involving ensure_ascii (issue #98)
Use Python’s repr() to emit float values instead of rapidjson’s dtoa() (issue #101)
Use a newer (although unreleased) version of rapidjson to fix an issue with JSONSchema validation (PR #103), thanks to Anthony Miyaguchi
0.5.2 (2018-03-31)
Tiny tweak to restore macOS build on Travis CI
0.5.1 (2018-03-31)
Minor tweaks to CI and PyPI deploy configuration
0.5.0 (2018-03-31)
0.4.3 (2018-01-14)
Deserialize from bytes and bytearray instances, ensuring they contain valid UTF-8 data
Speed up parsing of floating point numbers, avoiding intermediary conversion to a Python string (PR #94)
0.4.2 (2018-01-09)
Fix precision handling of DM_UNIX_TIME timestamps
0.4.1 (2018-01-08)
Fix memory leaks in Decoder() and Encoder() classes, related to bad handling of PyObject_GetAttr() result value
Fix compatibility with Python 3.7a
0.4.0 (2018-01-05)
0.3.2 (2017-12-21)
Reduce compiler warnings (issue #87)
0.3.1 (2017-12-20)
Fix Travis CI recipe to accomodate MacOS
0.3.0 (2017-12-20)
Fix compilation on MacOS (issue #78)
Handle generic iterables (PR #89)
Backward incompatibility: the dumps() function and the Encoder() constructor used to accept a max_recursion_depth argument, to control the maximum allowed nesting of Python structures; since the underlying function is now effectively recursive, it has been replaced by the generic sys.setrecursionlimit() mechanism
0.2.7 (2017-12-08)
Restore compatibility with Python < 3.6
0.2.6 (2017-12-08)
Fix memory leaks when using object_hook/start_object/end_object
0.2.5 (2017-09-30)
0.2.4 (2017-09-17)
Fix compatibility with MacOS/clang
0.2.3 (2017-08-24)
Limit the precision of DM_UNIX_TIME timestamps to six decimal digits
0.2.2 (2017-08-24)
Nothing new, attempt to fix production of Python 3.6 binary wheels
0.2.1 (2017-08-24)
Nothing new, attempt to fix production of Python 3.6 binary wheels
0.2.0 (2017-08-24)
0.1.0 (2017-08-16)
Remove beta status
0.1.0b4 (2017-08-14)
Make execution of the test suite on Appveyor actually happen
0.1.0b3 (2017-08-12)
Exclude CI configurations from the source distribution
0.1.0b2 (2017-08-12)
Fix Powershell wheel upload script in appveyor configuration
0.1.0b1 (2017-08-12)
Compilable with somewhat old g++ (issue #69)
Backward incompatibilities:
all DATETIME_MODE_XXX constants have been shortened to DM_XXX DATETIME_MODE_ISO8601_UTC has been renamed to DM_SHIFT_TO_UTC
all UUID_MODE_XXX constants have been shortened to UM_XXX
New option DM_UNIX_TIME to serialize date, datetime and time values as UNIX timestamps targeting issue #61
New option DM_NAIVE_IS_UTC to treat naïve datetime and time values as if they were in the UTC timezone (also for issue #61)
New keyword argument number_mode to use underlying C library numbers
Binary wheels for GNU/Linux and Windows on PyPI (one would hope: this is the reason for the beta1 release)
0.0.11 (2017-03-05)
Fix a couple of refcount handling glitches, hopefully targeting issue #48.
0.0.10 (2017-03-02)
Fix source distribution to contain all required stuff (PR #64)
0.0.9 (2017-03-02)
0.0.8 (2016-12-09)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for python_rapidjson-0.9.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b11b523ba060fecadf306eeea597645fed287369971bddac1e5bb76e9bff016d |
|
MD5 | 81fa2f944bcd3d1679278da6d805456a |
|
BLAKE2b-256 | eab4e064ceea982a202404d059dcf37c4aee87ae0b088a4ce94822e4f825ccf5 |
Hashes for python_rapidjson-0.9.1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26bfff41f0206f6f1df42c31a4c0d7c8de1e0fb57731707a0e04fa094f8bb7e1 |
|
MD5 | 142d199958572e5939525e9dcb237157 |
|
BLAKE2b-256 | 4262f5a21f199a6c31d52cb97e6c79ebcd77a35ec44a4ccfb10d14c64fdf23d8 |
Hashes for python_rapidjson-0.9.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3eee83134adfec5644821c10f776839ee78f9321c691af0116d8fb4331caeb32 |
|
MD5 | ecd2d7464e5713e95438a18e61b05c08 |
|
BLAKE2b-256 | f632ef426b5f8cd2ad4a2338496b92755d85d5202cdf984370fded401c281435 |
Hashes for python_rapidjson-0.9.1-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c86d6b499603ece6c487cb45d757f7ee1cc8f8a5dc9e1a5548ce54cd763ffe48 |
|
MD5 | 045ea482e13ebfc9d368eb85355fbd8e |
|
BLAKE2b-256 | 290a12843769eaf4986df84c248be02b9e2ff2e7adf6321e03020e28282ea32e |
Hashes for python_rapidjson-0.9.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f81061d34e1510ab284e0c447e7b68dc6f3989260f57d84b3f335e10433692ca |
|
MD5 | 02985558bc8106c186e8c1c9c1aa5b6b |
|
BLAKE2b-256 | ef08ef2a299423abbd8701cbeb0a1e7435283ca9e9cc31981b2febd81eac409d |
Hashes for python_rapidjson-0.9.1-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 887026e57e5a142d31d06087ecee556062d83ee1c4dca81230c8d2a6a4cefc40 |
|
MD5 | 409ecdb18d6bb5650c2118e1b6b52e21 |
|
BLAKE2b-256 | a0a8b91749ee10ffde441f578ef79c6363f6b5b89182cf0a10f0ad0f84632881 |
Hashes for python_rapidjson-0.9.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c3f37212499fab32abc3d53d591231e9fe99668f6a93faf8d17de30cdaf80a3 |
|
MD5 | e2df7036800a018160b1c856f4431a47 |
|
BLAKE2b-256 | 071a3ef8a1014ad2b60b42c264f35d36dde3733c3f82bbc99286bbc5bb3a3eb8 |
Hashes for python_rapidjson-0.9.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad554220dd5903f67765f69698c9c0be50ad67cc989ed9f406c2c19c73d8f2f3 |
|
MD5 | 1956e951294a6b0ad41447a69954fbf1 |
|
BLAKE2b-256 | cad5356b6d8daf020fed5ee10e734d75067853afa51465f39a44827cc73c3dbe |
Hashes for python_rapidjson-0.9.1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70fbeacd28582a9be0b1fe521c14a9fa7d62d624616325de9c55dc53001f6715 |
|
MD5 | 2d74ffc722d1a285d91d2881c3619d02 |
|
BLAKE2b-256 | fe99cba9290d417576aa3bd573d12544fcba62926b0218b0b27287e2a40a24e4 |
Hashes for python_rapidjson-0.9.1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47bb70892452a14729a76e08bb60ba5f9628f5c6ee6a9a0c648fa3c6e543f019 |
|
MD5 | 13d168a41c409eedfb5edf30ba5b8c1e |
|
BLAKE2b-256 | 1a905c164d14c0f83562ef2d45595f22e6796361ec9828e7bdf2036e85c67249 |
Hashes for python_rapidjson-0.9.1-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 602904892022bef8b1a1e4dc633c052e400d66652fcf0313167d4e227718629c |
|
MD5 | c508028d9de8ee8dd1036e9054cc4955 |
|
BLAKE2b-256 | fe4105416a4889b772e77913e2d418fbb4c6bd3ba8519556394dac505b193f5a |
Hashes for python_rapidjson-0.9.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc43e5376d8a1243c82e27397011bf03297e94242d45fad2f7b7b1561bf29615 |
|
MD5 | 5636b507d1e5a6631d01ff5c21e81c95 |
|
BLAKE2b-256 | 5f0d8a5f5b33df95d5370b07941439b59fd635da56847f10260bb614f2f5cf42 |
Hashes for python_rapidjson-0.9.1-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c31e659b9720358533e2774fac12f5e5c4ea8cd45e6629fc8eccad0d8f421552 |
|
MD5 | 4932a5d60e3d03a089e6dd9dd5924f5b |
|
BLAKE2b-256 | ea9958b5f585e61265b64baa65808fdd50094f6d646192616b50c9ffe794f04e |
Hashes for python_rapidjson-0.9.1-cp37-cp37m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e00de6ae6a4c0f91a9096fdea79d4c074166578a431ad4141b678d4531be081 |
|
MD5 | 4009e50f930589bd44cd8738555dbb26 |
|
BLAKE2b-256 | 8fa28e7f822889d3fca7e15713ecde25654bef60047f1fce263e3e55e0c233ac |
Hashes for python_rapidjson-0.9.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12eab9675a75dd14c07ee851429a5465f051aa1ebf66ade093fb15f0dc3159a6 |
|
MD5 | 28ebce10d8275a4d2ddc863f6da211e9 |
|
BLAKE2b-256 | 6200f6be4242c5472196d4e4dd46fff3f42d0a4f030cf026f040094f7c902802 |
Hashes for python_rapidjson-0.9.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7321bd3b7c96417f0c3d83c1b40d350e0f4893549881bdb384dadf08034f7975 |
|
MD5 | 6ed6e2f16531f9ae31ec9eeda73025ae |
|
BLAKE2b-256 | 69386e751f8f4923ad8ddeaf1a82a04f1c5757974a2ec988715aed451b621f40 |
Hashes for python_rapidjson-0.9.1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c687dd3b2566dd8fbee4d24b484d35e17b4be9edea720a6601fcf65f39f9b1cd |
|
MD5 | ba63ba92fd94f251f3b6ee3919321cc7 |
|
BLAKE2b-256 | 9ecb085b893850110d4e20ef3624808ccaec0515c07da0400e58bdd3ca73c5e3 |
Hashes for python_rapidjson-0.9.1-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dab0d99456537e180da9f311aff70712a165c6c362dc4da5fd766ab53869bb64 |
|
MD5 | c9f34f09d28f30f056e0f252ff386450 |
|
BLAKE2b-256 | a1e33c83765b2be3a748ad66eb4ab7de49f13d576d76717af5e573bc5510a7d6 |
Hashes for python_rapidjson-0.9.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e129f8c5a098aa7d066fe7ca3a99411010bf3ca1dc17525d4869c77e2dd4351 |
|
MD5 | 36dacaf399c522a935baf50903d61575 |
|
BLAKE2b-256 | 612cec819d4603da706a80c4b20583b2ed7df89b6a0fc8467f090b45908f905c |
Hashes for python_rapidjson-0.9.1-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fc885de12a35699ed7e4ec9fa56ec791d1d2404269398bf989543e6b324c7fd |
|
MD5 | 6377521a24b9eeada11aab1b151d7b61 |
|
BLAKE2b-256 | 6afad4cb4a99c5138eeb64b454b07f9f2acf814a9cef3d654b90bad73acea213 |
Hashes for python_rapidjson-0.9.1-cp36-cp36m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 541935d6ef72d6e665acbb649144d4f7aa364e54b0d3c6689b5d427bec2b07c2 |
|
MD5 | 16185df4c681b120b8fc57262bacf355 |
|
BLAKE2b-256 | 7ec41825f143ea6102fd007727009553a63f0d24dedcb41a0048b7cd7cb62009 |
Hashes for python_rapidjson-0.9.1-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 292fdd82d4cc3e81b01b46717b969fbba56d19e70708e545e7d86c70cc11596a |
|
MD5 | 8e423ee7fa26be3080e3062f3bad6313 |
|
BLAKE2b-256 | 6d3552967eec520d9d4ed1abc2d61fdfc0a35294fce78efa51aa9d6568c2aee3 |
Hashes for python_rapidjson-0.9.1-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 680a476d41f95cdc7292d17fcb1fcf54445f08e9ca1c5fba2a6067016b42a859 |
|
MD5 | e6af1fc8dfccff763c4d2b92187e2156 |
|
BLAKE2b-256 | 4b047d1454a0748016c3f6e00772b7108a4be4ae6d4178810a305eb711ec0d95 |
Hashes for python_rapidjson-0.9.1-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8d26ceb35495a885c4dcf8d28946ae2a878dc749d3c0fedbf0df6e6f5d99f06 |
|
MD5 | e14ba5c427b2c3387054e3ff71e39c14 |
|
BLAKE2b-256 | 88139ebad0f2d1ff0186898b30c155d7878b2b6aafe12bfe2705272ec0884e24 |
Hashes for python_rapidjson-0.9.1-cp35-cp35m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5647c1df3cd2253d16192795c61aeb7be37c07d007179aaeac014992cddc937c |
|
MD5 | 8ab0c11e2c8800a237ae3971908e2442 |
|
BLAKE2b-256 | 0090ed0d3d7468d64de5e070ea8ff21a55c27b8dcfa6b31a2406993670a84653 |
Hashes for python_rapidjson-0.9.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99c7896f14ddd7592842da5181ae6b2cf4362159cde7993875b72b93818a4840 |
|
MD5 | 3f1858bd82003eb251b8bb9493d27d7e |
|
BLAKE2b-256 | addd9ef98f26f47d892570775f4d308bb65434e29e4c216c51dfb695e1f9cebe |
Hashes for python_rapidjson-0.9.1-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 842c2298f91ecae60925bb133ad5dfb2793dcb909266b88d1d30eaabfd3f5199 |
|
MD5 | e48c7a6ccd7300f3d50c6493dc910c6b |
|
BLAKE2b-256 | 4c1f4c47ced9610870c595afbf8cca0750c59009c61cb79d172cd61067220c5f |
Hashes for python_rapidjson-0.9.1-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7d509a8c6192c6e57b5e2c005e8c6dd8d2f988776b3444af42a39ffda38f6a8 |
|
MD5 | 6f98de30eb61ffbaf78cdbcc4536cefd |
|
BLAKE2b-256 | 1cceca9e55f73c574673efe9f2489a64bcf7c0283725d9013467f0f9abe71af8 |