Skip to main content

Ultra fast JSON encoder and decoder for Python

Project description

PyPI version Supported Python versions PyPI downloads GitHub Actions status Travis CI status DOI Code style: Black

UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 3.5+.

To install it just run pip as usual:

$ 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]""")
[{u'key': u'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(u"\xe5\xe4\xf6")
'"\\u00e5\\u00e4\\u00f6"'
>>> ujson.dumps(u"\xe5\xe4\xf6", ensure_ascii=False)
'"\xc3\xa5\xc3\xa4\xc3\xb6"'

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 indention (“pretty output”) is enabled. Default is 0 (disabled):

>>> ujson.dumps({"foo": "bar"})
'{"foo":"bar"}'
>>> 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ujson-3.1.0.tar.gz (7.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ujson-3.1.0-cp38-cp38-win_amd64.whl (44.0 kB view details)

Uploaded CPython 3.8Windows x86-64

ujson-3.1.0-cp38-cp38-manylinux1_x86_64.whl (178.0 kB view details)

Uploaded CPython 3.8

ujson-3.1.0-cp38-cp38-manylinux1_i686.whl (169.0 kB view details)

Uploaded CPython 3.8

ujson-3.1.0-cp38-cp38-macosx_10_14_x86_64.whl (45.1 kB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

ujson-3.1.0-cp37-cp37m-win_amd64.whl (43.5 kB view details)

Uploaded CPython 3.7mWindows x86-64

ujson-3.1.0-cp37-cp37m-manylinux1_x86_64.whl (175.8 kB view details)

Uploaded CPython 3.7m

ujson-3.1.0-cp37-cp37m-manylinux1_i686.whl (166.8 kB view details)

Uploaded CPython 3.7m

ujson-3.1.0-cp37-cp37m-macosx_10_14_x86_64.whl (45.0 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

ujson-3.1.0-cp36-cp36m-win_amd64.whl (43.5 kB view details)

Uploaded CPython 3.6mWindows x86-64

ujson-3.1.0-cp36-cp36m-manylinux1_x86_64.whl (175.8 kB view details)

Uploaded CPython 3.6m

ujson-3.1.0-cp36-cp36m-manylinux1_i686.whl (166.8 kB view details)

Uploaded CPython 3.6m

ujson-3.1.0-cp36-cp36m-macosx_10_14_x86_64.whl (45.0 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

ujson-3.1.0-cp35-cp35m-win_amd64.whl (43.5 kB view details)

Uploaded CPython 3.5mWindows x86-64

ujson-3.1.0-cp35-cp35m-manylinux1_x86_64.whl (175.8 kB view details)

Uploaded CPython 3.5m

ujson-3.1.0-cp35-cp35m-manylinux1_i686.whl (166.8 kB view details)

Uploaded CPython 3.5m

ujson-3.1.0-cp35-cp35m-macosx_10_14_x86_64.whl (45.0 kB view details)

Uploaded CPython 3.5mmacOS 10.14+ x86-64

File details

Details for the file ujson-3.1.0.tar.gz.

File metadata

  • Download URL: ujson-3.1.0.tar.gz
  • Upload date:
  • Size: 7.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for ujson-3.1.0.tar.gz
Algorithm Hash digest
SHA256 00bda1de275ed6fe81817902189c75dfd156b4fa29b44dc1f4620775d2f50cf7
MD5 875ac729018f3cac786d471422306fa8
BLAKE2b-256 4323c2362e88248c169a3ff3e2cbe2d6d6ba5345260658476479b6e8703d4274

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 44.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for ujson-3.1.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 bf30ac68d8b2aed665589cfd3608e43d8cd6cb74cd5a9379ab9af9861c33a8be
MD5 012c7b61acf0a8fc6243b40af8ee923c
BLAKE2b-256 f22f71cea71e35e954b43635ccbbc19a7eedcb30591cfd4178b3d7d54dd24053

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 178.0 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for ujson-3.1.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8032ca897cfce113cb9ca7f07ff4c750afe18c605eeed2e09cf9b882c99fc76b
MD5 5d5f042f199db755f41fc0e5adba15d2
BLAKE2b-256 206f729b2d2c1ceb7357861538fed6aa78d9fcf9ae923b96e2649a1526012d1a

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp38-cp38-manylinux1_i686.whl.

File metadata

  • Download URL: ujson-3.1.0-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 169.0 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for ujson-3.1.0-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 0184ed23618ce3d793aaf9f5b3dd456cf719b930d3936fb39000589ed0bd2811
MD5 19fe8546038203056587b86fbb4b2e26
BLAKE2b-256 94ac43c9464163524e65167872b0009add9b52167bde322e08f32c071497e69b

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 45.1 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for ujson-3.1.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a8194b778adf38ad679c62e2bb6cf71972ae91102e611e4bb31f625be6fb366a
MD5 3041bb6ec391d707ddfca8ecd7ab4b7c
BLAKE2b-256 b8fecb11147ce90ef7619bc41dacf945be3ba661d9c65c8d3c4af033c7c96f25

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 43.5 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for ujson-3.1.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 7e7cdd8a42428cd2716cfe0a506e57168c6a02b8032478209cb4a8a12b8c2c4e
MD5 8bee6e375c37c84035afff2486d0604d
BLAKE2b-256 a74b6045ef8e4745350fdeb4f2f735f0290ca41a7df60e3f55392d5c22ccb900

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 175.8 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for ujson-3.1.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c2be0d511e5dc302f190e510544c4d5fbbb4396632abe33b66e28dad26ea4325
MD5 b566f41ee04e7dcc5dc5b0481ef4646b
BLAKE2b-256 650ea7475d349508e2bf2e7187610f3ff9119e08423c3f6b551cff5302a78978

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: ujson-3.1.0-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 166.8 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for ujson-3.1.0-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 3a049acf176dacbb79ee00b13a78fc2524c35c69400e34aa5f6ff0fc3fdbb1f0
MD5 890ad93789a7fdbb004f22155173b88d
BLAKE2b-256 d6f09cdbc6c47db5c028afd60a9d56dd4b16f7206909f1227d31dc2fca8e6cc7

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 45.0 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for ujson-3.1.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d3f28f64b33609be20f985baa72d43ccfdf87e50d47ca2791d26b9c2f348a35b
MD5 b148e2f47a25e443ea19af63845b0519
BLAKE2b-256 b84f4b95ceeacb6095c09b49db293a10444bfc5bb670fd62575e0a3cb7fee17c

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 43.5 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.8

File hashes

Hashes for ujson-3.1.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 083778f4e64f90b4468e73e0baafcde0ab83bff85315d28a5b1287a3f5909e7f
MD5 7f4f9d0c42737f6d9ea8e08e5811b061
BLAKE2b-256 fda9e02977d03b3fb1f48ae62e2a65f30d37e2601abff4469efcc966f0c80d9b

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 175.8 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for ujson-3.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6a2fac9892996c3a46bd3fd8bbf739f19f85fc7ec9cdc11b014f76267c3ee76d
MD5 309fef55ce26c840b71e19c760722619
BLAKE2b-256 be1a36ead6ae1bc3b82ea864ef87f8c8e1e06bec3a745dc65915f47b46f241d0

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: ujson-3.1.0-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 166.8 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for ujson-3.1.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ebe1bc9536b93c697f042b6c39ed602ad7edd5ef139eb167d9c8e36594b24546
MD5 4aa22198638c5438c3d6c7629b4eae95
BLAKE2b-256 af57e8c8fa48582757337f8ecbeca656f6595cb9e6f78be2a68a0814f66efcec

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 45.0 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.11

File hashes

Hashes for ujson-3.1.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 f6e229fa9b7d8586f894d18a003703fea4620ff8e6d39c11499755ecec5b43fc
MD5 33f5ed864c43527b05c77b701d01d56b
BLAKE2b-256 cc124c46ae203e1f8eea8cdab8b10d3c63c288c8ec6cc50079cba584fbf7a971

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 43.5 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.5.4

File hashes

Hashes for ujson-3.1.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 0789837e7156e07890f2461ec1d9dc2ea4ef7c76fd36e46955d811485daf83b9
MD5 59fe7c820199146aaa557f26db361138
BLAKE2b-256 4b6f47e6561152bf3a17eac64b665ba62d3f6a7578988d9f6718e5c910fb54da

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 175.8 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for ujson-3.1.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b794a2ddba049daa1fe0f28c4652b54d0d06580e7d3bcae87b4c000fb242654f
MD5 8309d4412918a0b39068a2cd040233d2
BLAKE2b-256 c07c8686b5553a78c728baaa64b5d1fcf9a4229547081fe6c6c8f825189ecb7e

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp35-cp35m-manylinux1_i686.whl.

File metadata

  • Download URL: ujson-3.1.0-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 166.8 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for ujson-3.1.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d40d53aa679994624960b1c40bc451c5d9e3a0779f6a04146b417e220ce8f7d4
MD5 e3ce5e4cde40d593d67a900b0f16780a
BLAKE2b-256 ce09a3017c8eba0d140b7a0204d34614f72a8eb387bd9121286c7191ae695e5f

See more details on using hashes here.

File details

Details for the file ujson-3.1.0-cp35-cp35m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: ujson-3.1.0-cp35-cp35m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 45.0 kB
  • Tags: CPython 3.5m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.5.9

File hashes

Hashes for ujson-3.1.0-cp35-cp35m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 585329c16eeb0992308545c7a05eee76c7f1c2042b08317aac64fef1e71e71a9
MD5 fb629118cc42fe8c1c52d544c827b39d
BLAKE2b-256 f9ddf05a9d3c49aa6d4ce8a56975c1943ae08cb27af1eb8dbc4ae2ca3aff827f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page