Python wrapper around rapidjson
Project description
- Authors:
Ken Robbins <ken@kenrobbins.com>; Lele Gaifax <lele@metapensiero.it>
- License:
- 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)
'{"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.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.6.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47587055b65199478900c7362cf6af33c041bfc10c54e12513657b25aabf40e9 |
|
MD5 | a8fd9ebdc1c434167b142859377e5414 |
|
BLAKE2b-256 | 1dcf3113ba28a5e477c26fe871db9ec6f5da2e49439cab229e71eed66fb645d8 |
Hashes for python_rapidjson-0.6.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d5bb2c8e5ed4a9418321988c892dba225e9420123d01831d6203d2d0ff3462f |
|
MD5 | 12dcc270d70ecc16d30d65f49dcfc4b4 |
|
BLAKE2b-256 | ecb43d776f4372e0aff772704cbbb4e07faaae09ac30183696eeacf535b2f9bf |
Hashes for python_rapidjson-0.6.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43fc853df5ddb4f0aacb5cd2c1ed9135e3840e5f772ba66768706c3c76a2061f |
|
MD5 | 723022294160cef41228bc7e4b4b270c |
|
BLAKE2b-256 | aa6004e388a8dea43a67c92847719a8538fac4fcd6dcc1c5de9b7ba56c77808d |
Hashes for python_rapidjson-0.6.0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1673ca6395f929e8f8acddd6c47e8675b20bf8b90a672f7b2d1efe3ff1fb936c |
|
MD5 | 327c9fb975ec0673d28b646db91c01f5 |
|
BLAKE2b-256 | e9649a5b963ebbb5496bdbb95bc7ba00a238e0cfe8cc7b9f2260ff6659ed9b7d |
Hashes for python_rapidjson-0.6.0-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a84b4a279b26078d2d219ed29393e6c1d11e12aba039d3931d0fc0deb6ed21e0 |
|
MD5 | 37826243f49d90b91f8814d9525b2e9e |
|
BLAKE2b-256 | 38854e67bdce62a0bf4ed948077f2f64e377adce77dd0daf0f71db36319bfbb6 |
Hashes for python_rapidjson-0.6.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bb241c694c693f0c64a69092078fb66accfbd3bb501dcbaf995b1246ab4f8df |
|
MD5 | 90868118227cb6be1c8935b896c34da4 |
|
BLAKE2b-256 | 0fc9fa3d5d085b7adaa2249d8f50df294083d30443b633fc77be220e132d7ca6 |
Hashes for python_rapidjson-0.6.0-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf2db524ca15a6c4470354e5069fc11abea736b6cfb5f0f12f4233977af6474b |
|
MD5 | 3eddb94b5276aad31a73133247666e87 |
|
BLAKE2b-256 | 1b479e1a98d1880be05af9cfdf3c3433afe23d84aed52e171f9a3be150b9d6e4 |
Hashes for python_rapidjson-0.6.0-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fc765cc97fd81bc973101def6d87fc522f955520ae60cb3a82445773f17b780 |
|
MD5 | 6b80e4c3ccfd9f9b2b51c938c1a55929 |
|
BLAKE2b-256 | ce2d1a1b80c6c608093df800a86529720ce5e8d49e3dfdebcddf3191d6194861 |
Hashes for python_rapidjson-0.6.0-cp34-cp34m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 309bb27cc94f95a5c7c37005cd2ca3fc020b65809bae98cff8f26f541db84433 |
|
MD5 | 4ccd1d1239f9d4fda4857726276d8139 |
|
BLAKE2b-256 | 2095b901a6bb4643853c3a45781bb827614bde7f89b1f9b7b339acb8b82c9729 |
Hashes for python_rapidjson-0.6.0-cp34-cp34m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 895ad7ae33a13d2dbbe2583360743790fa8d54a7b431512da55ccb8131b3d14e |
|
MD5 | bc6206049ed0e2103c8abcec4221b5d9 |
|
BLAKE2b-256 | 14c74ef5b0e79c30e160cc7d8d8ac66d03707e9f96d696268cf3477d6b3fcfdb |
Hashes for python_rapidjson-0.6.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60fcc69752003da33b577b7072f8145aac146bbd3be8f6953e6fdc36cf08bd46 |
|
MD5 | 0e62b93c86e6b5f5e7e3687f4d4ca311 |
|
BLAKE2b-256 | cbaeda2b26156f3a777c12fa797fbbc3f59b8fc070d9cf1199d99ce46158c603 |
Hashes for python_rapidjson-0.6.0-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be437a34ba5b4370942e9f45f9bebd73e163d64e1030eac5c49caaa4122c93c0 |
|
MD5 | 5d814b16385744cb93ae537b0070815f |
|
BLAKE2b-256 | 8feae303a46d651436e02e42440103cc91297b91e4ab68caa6d2b3ae1f4de501 |
Hashes for python_rapidjson-0.6.0-cp34-cp34m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d5ea99a779348d1ee4fb9a898ec0cfb77d81a9a7474d667e0f8b2f0354872d5 |
|
MD5 | 4156691b825e85191d4a00f4157068fc |
|
BLAKE2b-256 | 4f7db019e9ab0e0f9aedbcc6a35cb98195acebba60a3de44aa093266aa45100d |