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.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.7.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5da843323b270b5fffec8db35c3481da66d5098390745471f6b2b4c55750258d |
|
MD5 | 73d70c5fdb0604c042d406516eb0e833 |
|
BLAKE2b-256 | a1795c6e2b57895ca40d9b0bd0db3f5b359f5116537cf7bcc147c8700ab7f5ab |
Hashes for python_rapidjson-0.7.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a80b6d4f5fd5533bc677bc7e1bb6222dcaea979270f21a335ea2ababc9dc2068 |
|
MD5 | 58efbd6d72edcca497b2bc61115280e1 |
|
BLAKE2b-256 | 18488dc75cf61fb8d1a94fb37361f94c6e8e1d4a3821144605e56249bcf97e76 |
Hashes for python_rapidjson-0.7.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d80a6b2a6c2ae1541e10a871462b0c3a7a94276c2129d06f2cf0f41331e78f8 |
|
MD5 | cdb14ee4ed4a502dcd68c212c595b891 |
|
BLAKE2b-256 | fcb532f95d39a03c80780a3b5dfb633b85877647474f5cfef1df04a828de92ae |
Hashes for python_rapidjson-0.7.0-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0643d0350a02db7d292ecb62ec9e71d9ae9d591ee3023a0a1a076e0b8596f372 |
|
MD5 | 3c49d81720f023728e1e4489350b388c |
|
BLAKE2b-256 | de28a1dbc0049a3092cb6c1718f6e8f8f9c00e525128d820a636b73ecd1e6dd2 |
Hashes for python_rapidjson-0.7.0-cp37-cp37m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da45731d4843ec3d32bcc98213f6abeb07b36720e501dc1c230258be8407661d |
|
MD5 | b0a9dcf6805edd712250ce14708d4814 |
|
BLAKE2b-256 | 82e0fda022cc9779efc4766c653d082494fe6a1a69d0d1dca88da3c3039f77ed |
Hashes for python_rapidjson-0.7.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 243e88f9951998dcac4ce1a2ec72b097461b32196dd662736d9d654dea3a5519 |
|
MD5 | 03be4fd19d9928c30bae20a5f6e977a3 |
|
BLAKE2b-256 | a131a0faf10c661d172f3ecd5acad3b120b322deaad88ccf51488e4cf8ad611a |
Hashes for python_rapidjson-0.7.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66def431459287561c9b86a85e42459bea0059961850a14784ebdcde55b50fce |
|
MD5 | a7177a0fb80926c81ee8c7a096c126dc |
|
BLAKE2b-256 | d7b3bb66b5b3c12a8128e34eee9d9f7aa7cb0d6d8ba21d9608a0db7cf3f31652 |
Hashes for python_rapidjson-0.7.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e13963d4491e0835802598a00324dcdc3cc62fe7f8590894dee1299900ce89e |
|
MD5 | b355e7188b1d045886b03b050bd5d6da |
|
BLAKE2b-256 | ec844d28733eb0e97eb945abb4fbd2355ce3e1d18221b90593ecfa0b9711b3c6 |
Hashes for python_rapidjson-0.7.0-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc022efe8bfc281f1ae4844a9fa2cc64f3e4513da362c6866ae5c3a9434c1c92 |
|
MD5 | 9bff0dde9a2bbb6338fc8106764d4de3 |
|
BLAKE2b-256 | 310ad092eedb5ce984cb15461a53c51c434b8975b4538f9cceeeafabf4f23f3a |
Hashes for python_rapidjson-0.7.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e90c5d7e9b6d575ded78135ea986f54d82c063c887649954a3006d3b852985c |
|
MD5 | 63ec01a7e616398d9008f22bcdcc1bfa |
|
BLAKE2b-256 | dcc8f09025b126bd3ef6b1aa13aaf0bd1e7f0fe61c4efaef254b4cc24eb09b5e |
Hashes for python_rapidjson-0.7.0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea20af1aececb0ad13a7a14237898d6a0cfc321eb6fdbd6c9fb33a77c42f1f7d |
|
MD5 | 721f61c80cbfa294ddc5ca96fe8752d9 |
|
BLAKE2b-256 | 270fee12ebcf6019a7bb39b183f6a0505aceea33d55f40303cb653dbc34eb08d |
Hashes for python_rapidjson-0.7.0-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a106ca99f1f20d811a3d028322501aefeb8af5ff333e3450aa4376807d710fbf |
|
MD5 | adfcb40be1c9214c3325e915e26da48c |
|
BLAKE2b-256 | 86df26b02f5ef9e1223828c731ba2a92cb82ff16f794ccc16c398f20a8c04110 |
Hashes for python_rapidjson-0.7.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c416049f28e864c85ad51f78d7ad17632b2505e977ebbc337247d50981a01982 |
|
MD5 | 405613c24903c65b671b69aded0bca36 |
|
BLAKE2b-256 | ec0f67d1ddb7e17ddbccd29822d392d30eba9943fb5ed4a60c4cb980a9359c83 |
Hashes for python_rapidjson-0.7.0-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7beff614a90a716dc891f074528fb93a0208d930b2e0a86007de3510135b17e7 |
|
MD5 | eeccbf8a5cbe1084c321c7c0a4dd96a2 |
|
BLAKE2b-256 | 815ecd9aba97f837223ead6bc88da16c4ef383a95175ab002c0902f54f3eaefb |
Hashes for python_rapidjson-0.7.0-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 228873f709991c1ff4172e59fe0b14b5dd98855b4408267cffed544ec120489f |
|
MD5 | 402bcbe84017d4de9345ad5861e4ee9c |
|
BLAKE2b-256 | 50982ca40bd73e99cc247848a7c359e1137d0520a9bcc30dd1db48a4e54d426b |
Hashes for python_rapidjson-0.7.0-cp34-cp34m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bcf53c99d110a7489f4cf938162f8117d34dd8a7324e1ca30b7eaffd6c780ca |
|
MD5 | 1c44bc78dfc143a593549ce00d5383e6 |
|
BLAKE2b-256 | aa6497007184ad01178b62cb3a6c7e9b71a54dcdd72f1113277d406b6b439a4c |
Hashes for python_rapidjson-0.7.0-cp34-cp34m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cc087906963bd362fd09ee5c1111a952a5a7172b71429d9f52533ac12f34d67 |
|
MD5 | dfb7af32d04baf420e5d917b75efd667 |
|
BLAKE2b-256 | 1646f968d41295524fac8cb384b906b2e88a3786847ddd070ef8d926bbb4164a |
Hashes for python_rapidjson-0.7.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f2475cf2f5f1ad3ccf3e415453816cce08ae88c7c97bceee7811d2a7c6ab20e |
|
MD5 | 80f70ff150257a8846d520e8f2fe5b95 |
|
BLAKE2b-256 | 566fa28554b6dcbb88c106e415f76eca9db680bacee47fae56b80dd494357de6 |
Hashes for python_rapidjson-0.7.0-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bbf5245f1ffd1c4f935755962ab40c917ea97dff32e223f36ca079da87c9022 |
|
MD5 | 9c2d681576998339acdcb7c46662f6c3 |
|
BLAKE2b-256 | 1b6eefe86682e209c281cb50ed7e17d81049d585b7d905e0ef75b223240af581 |
Hashes for python_rapidjson-0.7.0-cp34-cp34m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d9dd53dd298f4bb2e3595ad761b3e06b1db7b21f4c187c85bb50f4a8c453b38 |
|
MD5 | e08400c6ca748b55957703d8c6741ba0 |
|
BLAKE2b-256 | c704d78d25af520eaedd5cefc4ca1741d92bf31b9dffb358211629b9030288dd |