Ultra fast JSON encoder and decoder for Python
Project description
UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 3.6+.
Install with pip:
$ python -m pip install ujson
Usage
May be used as a drop in replacement for most other JSON parsers for Python:
>>> import ujson >>> ujson.dumps([{"key": "value"}, 81, True]) '[{"key":"value"},81,true]' >>> ujson.loads("""[{"key": "value"}, 81, true]""") [{'key': 'value'}, 81, True]
Encoder options
encode_html_chars
Used to enable special encoding of “unsafe” HTML characters into safer Unicode sequences. Default is False:
>>> ujson.dumps("<script>John&Doe", encode_html_chars=True) '"\\u003cscript\\u003eJohn\\u0026Doe"'
ensure_ascii
Limits output to ASCII and escapes all extended characters above 127. Default is True. If your end format supports UTF-8, setting this option to false is highly recommended to save space:
>>> ujson.dumps("åäö") '"\\u00e5\\u00e4\\u00f6"' >>> ujson.dumps("åäö", ensure_ascii=False) '"åäö"'
escape_forward_slashes
Controls whether forward slashes (/) are escaped. Default is True:
>>> ujson.dumps("http://esn.me") '"http:\\/\\/esn.me"' >>> ujson.dumps("http://esn.me", escape_forward_slashes=False) '"http://esn.me"'
indent
Controls whether indentation (“pretty output”) is enabled. Default is 0 (disabled):
>>> ujson.dumps({"foo": "bar"}) '{"foo":"bar"}' >>> print(ujson.dumps({"foo": "bar"}, indent=4)) { "foo":"bar" }
Benchmarks
UltraJSON calls/sec compared to other popular JSON parsers with performance gain specified below each.
Test machine:
Linux 5.0.0-1032-azure x86_64 #34-Ubuntu SMP Mon Feb 10 19:37:25 UTC 2020
Versions:
- CPython 3.8.2 (default, Feb 28 2020, 14:28:43) [GCC 7.4.0]
- nujson : 1.35.2
- orjson : 2.6.1
- simplejson: 3.17.0
- ujson : 2.0.2
ujson | nujson | orjson | simplejson | json | |
---|---|---|---|---|---|
Array with 256 doubles | |||||
encode | 22,082 | 4,282 | 76,975 | 5,328 | 5,436 |
decode | 24,127 | 34,349 | 29,059 | 14,174 | 13,822 |
Array with 256 UTF-8 strings | |||||
encode | 3,557 | 2,528 | 24,300 | 3,061 | 2,068 |
decode | 2,030 | 2,490 | 931 | 406 | 358 |
Array with 256 strings | |||||
encode | 39,041 | 31,769 | 76,403 | 16,615 | 16,910 |
decode | 25,185 | 24,287 | 34,437 | 32,388 | 27,999 |
Medium complex object | |||||
encode | 10,382 | 11,427 | 32,995 | 3,959 | 5,275 |
decode | 9,785 | 9,796 | 11,515 | 5,898 | 7,200 |
Array with 256 True values | |||||
encode | 114,341 | 101,039 | 344,256 | 62,382 | 72,872 |
decode | 149,367 | 151,615 | 181,123 | 114,597 | 130,392 |
Array with 256 dict{string, int} pairs | |||||
encode | 13,715 | 14,420 | 51,942 | 3,271 | 6,584 |
decode | 12,670 | 11,788 | 12,176 | 6,743 | 8,278 |
Dict with 256 arrays with 256 dict{string, int} pairs | |||||
encode | 50 | 54 | 216 | 10 | 23 |
decode | 32 | 32 | 30 | 20 | 23 |
Dict with 256 arrays with 256 dict{string, int} pairs, outputting sorted keys | |||||
encode | 46 | 41 | 8 | 24 | |
Complex object | |||||
encode | 533 | 582 | 408 | 431 | |
decode | 466 | 454 | 154 | 164 |
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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size ujson-4.0.2-cp36-cp36m-macosx_10_14_x86_64.whl (45.3 kB) | File type Wheel | Python version cp36 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp36-cp36m-manylinux1_i686.whl (169.9 kB) | File type Wheel | Python version cp36 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp36-cp36m-manylinux1_x86_64.whl (179.0 kB) | File type Wheel | Python version cp36 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp36-cp36m-manylinux2014_aarch64.whl (227.8 kB) | File type Wheel | Python version cp36 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp36-cp36m-win_amd64.whl (44.0 kB) | File type Wheel | Python version cp36 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp37-cp37m-macosx_10_14_x86_64.whl (45.3 kB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp37-cp37m-manylinux1_i686.whl (169.9 kB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp37-cp37m-manylinux1_x86_64.whl (179.1 kB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp37-cp37m-manylinux2014_aarch64.whl (227.9 kB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp37-cp37m-win_amd64.whl (44.0 kB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp38-cp38-macosx_10_14_x86_64.whl (45.4 kB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp38-cp38-manylinux1_i686.whl (171.7 kB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp38-cp38-manylinux1_x86_64.whl (181.1 kB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp38-cp38-manylinux2014_aarch64.whl (229.8 kB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp38-cp38-win_amd64.whl (44.1 kB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp39-cp39-macosx_10_14_x86_64.whl (45.5 kB) | File type Wheel | Python version cp39 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp39-cp39-manylinux1_i686.whl (170.6 kB) | File type Wheel | Python version cp39 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp39-cp39-manylinux1_x86_64.whl (179.7 kB) | File type Wheel | Python version cp39 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp39-cp39-manylinux2014_aarch64.whl (230.4 kB) | File type Wheel | Python version cp39 | Upload date | Hashes View |
Filename, size ujson-4.0.2-cp39-cp39-win_amd64.whl (44.1 kB) | File type Wheel | Python version cp39 | Upload date | Hashes View |
Filename, size ujson-4.0.2.tar.gz (7.1 MB) | File type Source | Python version None | Upload date | Hashes View |
Hashes for ujson-4.0.2-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e390df0dcc7897ffb98e17eae1f4c442c39c91814c298ad84d935a3c5c7a32fa |
|
MD5 | 47e5f890fac5b6e360222016f83e56f2 |
|
BLAKE2-256 | d078f6d485e1e9f0fc2ffd5e0c1ecfb306d0f56e763c8a03050c5c9d10d13f30 |
Hashes for ujson-4.0.2-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84b1dca0d53b0a8d58835f72ea2894e4d6cf7a5dd8f520ab4cbd698c81e49737 |
|
MD5 | fbd02d746486b7426060083ad7283161 |
|
BLAKE2-256 | b3362fce56dfbc0f9c100fd1badd5f9c2d585ee3a60493964fc7f7c22c0d013b |
Hashes for ujson-4.0.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91396a585ba51f84dc71c8da60cdc86de6b60ba0272c389b6482020a1fac9394 |
|
MD5 | 516c0ac65e952f6230e20020571e9952 |
|
BLAKE2-256 | 8d542a618356e54282e3f4fa0745cbddeed104ed5ff2930c98f2d9dfa9677af8 |
Hashes for ujson-4.0.2-cp36-cp36m-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb6b25a7670c7537a5998e695fa62ff13c7f9c33faf82927adf4daa460d5f62e |
|
MD5 | 76870518ab011b9a0b622eb005dc38e1 |
|
BLAKE2-256 | 68b677e58f25db7f91cc7e19ffc2961f4a0df2da5f1eafd6ea1624583f1c4ce8 |
Hashes for ujson-4.0.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8aded54c2bc554ce20b397f72101737dd61ee7b81c771684a7dd7805e6cca0c |
|
MD5 | 7bbd6595f963c6bfe4f2ff0c3a544a08 |
|
BLAKE2-256 | 2bf662ba08742050d3e6922d47fe4e9295331cbc108d946d0bf74f16cdab0793 |
Hashes for ujson-4.0.2-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30962467c36ff6de6161d784cd2a6aac1097f0128b522d6e9291678e34fb2b47 |
|
MD5 | 9d18e2aef6f5a0b43eb315d636ab18a8 |
|
BLAKE2-256 | 324984d979d75e4a01b92271b1451e31945eac0d5239bf481ba025af9ab271d7 |
Hashes for ujson-4.0.2-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc51e545d65689c398161f07fd405104956ec27f22453de85898fa088b2cd4bb |
|
MD5 | 9ff7caac7034fb7d0273d1e8acbb3d60 |
|
BLAKE2-256 | 7ca7e9f08e5e91eada924aae937d6d6f124f782a5627f5244068455a4f56872d |
Hashes for ujson-4.0.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6e90330670c78e727d6637bb5a215d3e093d8e3570d439fd4922942f88da361 |
|
MD5 | f390c48ac9cd8b76c1802c6f5b0ef4ff |
|
BLAKE2-256 | 174e50e8e4cf5f00b537095711c2c86ac4d7191aed2b4fffd5a19f06898f6929 |
Hashes for ujson-4.0.2-cp37-cp37m-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e1636b94c7f1f59a8ead4c8a7bab1b12cc52d4c21ababa295ffec56b445fd2a |
|
MD5 | 986f06ad56c1008d21e9671c1ed014ca |
|
BLAKE2-256 | 4358f2f7706e2972aea2f71f8ca34ee0b368947b4db452dbde8f81a98de63712 |
Hashes for ujson-4.0.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2cadeb0ddc98e3963bea266cc5b884e5d77d73adf807f0bda9eca64d1c509d5 |
|
MD5 | 3850b52dc42dd1a8d9cad5bace7122ae |
|
BLAKE2-256 | a9592b2288b8fc20682a4dda46acaca109f1ba7155150a1010e7293cd7ffd200 |
Hashes for ujson-4.0.2-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a214ba5a21dad71a43c0f5aef917cd56a2d70bc974d845be211c66b6742a471c |
|
MD5 | 68a1710e903d2dd4b11d2df8bca41b96 |
|
BLAKE2-256 | 78b2659552204cc09a9384b3b0545b193d970696bead80304d48bd950dbdcbc9 |
Hashes for ujson-4.0.2-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0190d26c0e990c17ad072ec8593647218fe1c675d11089cd3d1440175b568967 |
|
MD5 | 6064b755deb6d3658dbc2b856e23e48e |
|
BLAKE2-256 | e9c6139faee80755d7d51fe1ee29257dd2e6a120f784d88554a9e08591eb86c5 |
Hashes for ujson-4.0.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f273a875c0b42c2a019c337631bc1907f6fdfbc84210cc0d1fff0e2019bbfaec |
|
MD5 | 5a9517b6d5b23234880965adb04957d3 |
|
BLAKE2-256 | f0c6a32b23f9fcef9343066152fbecf9180a380bb6637d255d892abd46f88bca |
Hashes for ujson-4.0.2-cp38-cp38-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3a87888c40b5bfcf69b4030427cd666893e826e82cc8608d1ba8b4b5e04ea99 |
|
MD5 | b8ad803f2b01a6ea260c25b2d41873a7 |
|
BLAKE2-256 | 16daccec40c0702813b964048d01a17e88809e00a311a848b6f3932e5ecf539a |
Hashes for ujson-4.0.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7333e8bc45ea28c74ae26157eacaed5e5629dbada32e0103c23eb368f93af108 |
|
MD5 | 0c338e5ec99ac8e7e09c125aa6554fbd |
|
BLAKE2-256 | 21c7d4081ba3e930ccf46845d4e3c4684b67788f05721f4fa0f51e94f2db1e54 |
Hashes for ujson-4.0.2-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3a6dcc660220539aa718bcc9dbd6dedf2a01d19c875d1033f028f212e36d6bb |
|
MD5 | a3bd475371a8b6a5ae767ae5c04ca203 |
|
BLAKE2-256 | 35de7c91593d3e409ff075aa8522c4395e5b22b879ff27564d787bec4461e0d7 |
Hashes for ujson-4.0.2-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ea07fe57f9157118ca689e7f6db72759395b99121c0ff038d2e38649c626fb1 |
|
MD5 | 144d02c10f9ce4a091628e9d3cdc36bc |
|
BLAKE2-256 | ec011ed3f15fe82fb458b5e25e993d6ba46404a84810a5e066d4cc30219583d8 |
Hashes for ujson-4.0.2-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d6d061563470cac889c0a9fd367013a5dbd8efc36ad01ab3e67a57e56cad720 |
|
MD5 | 46407aefdaa4d526ed3f43dc4c137fb4 |
|
BLAKE2-256 | 4d165478eb05b5b5d452f22e844421dad3784eeb6fb408846040fa095e2b83e8 |
Hashes for ujson-4.0.2-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5c70704962cf93ec6ea3271a47d952b75ae1980d6c56b8496cec2a722075939 |
|
MD5 | 2b09782f6bbb1e47a3bd60cb049b09ea |
|
BLAKE2-256 | 7e0ec20c66b0c8fbdcb2c2e2a48b146fea02e3fd081e6713d8a1b120be7572da |
Hashes for ujson-4.0.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aad6d92f4d71e37ea70e966500f1951ecd065edca3a70d3861b37b176dd6702c |
|
MD5 | 5d9d11949aeb3ba665d4eb6c97e6877c |
|
BLAKE2-256 | 3cb720882204f86a7379ace72a99d1a62fa0b8e1792a927de0cf0dbe8b0bbba5 |