Skip to main content

High-performance JSON parsing and generation powered by BMB

Project description

bmb-json — Fast JSON Parser

Zero-copy JSON parser and serializer compiled from BMB.

Installation

pip install bmb-json

Quick Start

import bmb_json

bmb_json.validate('{"name": "BMB"}')                  # True
bmb_json.get_string('{"name": "BMB"}', "name")        # "BMB"
bmb_json.get_number('{"version": 97}', "version")     # 97
bmb_json.array_len('[1, 2, 3]')                        # 3
bmb_json.array_get('[10, 20, 30]', 1)                  # '20'
bmb_json.stringify('{ "a" : 1 , "b" : [2,3] }')       # '{"a":1,"b":[2,3]}'
bmb_json.get_type('{"a":1}')                           # 'object'

Full API (12 functions)

Function Description Return
validate(json_str) Check valid JSON bool
stringify(json_str) Roundtrip normalization (minified) str
get_type(json_str) Root value type "null" / "bool" / "number" / "string" / "array" / "object"
get(json_str, key) Get value as raw JSON str (empty if missing)
get_string(json_str, key) Get string value (unquoted) str
get_number(json_str, key) Get number value int (0 if missing)
array_len(json_str) Array length int
array_get(json_str, idx) Array element as JSON str (empty if out of bounds)
has_key(json_str, key) Check if object has key bool
object_len(json_str) Number of keys in object int (-1 for non-objects)
get_bool(json_str, key) Get boolean value int (1/0/-1)
count(json_str) Count elements (shallow) int

All outputs cross-validated against Python's json.loads / json.dumps.

How?

Written in BMB — compile-time contracts prove correctness, then generate code faster than hand-tuned C.

License

MIT

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

bmb_json-0.2.0-py3-none-win_amd64.whl (87.9 kB view details)

Uploaded Python 3Windows x86-64

bmb_json-0.2.0-py3-none-manylinux_2_17_x86_64.whl (69.8 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

bmb_json-0.2.0-py3-none-macosx_15_0_universal2.whl (50.7 kB view details)

Uploaded Python 3macOS 15.0+ universal2 (ARM64, x86-64)

File details

Details for the file bmb_json-0.2.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: bmb_json-0.2.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 87.9 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for bmb_json-0.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 f506e2fc2d2d37824024c504f55194947e71b27e9896437d6fb631bb317573da
MD5 b8639ba25e6e36f15240c0786e9b4442
BLAKE2b-256 792a7e8bf9de74ca58adb940972736a80f2262b6335f4e2b7876a180cb2ec167

See more details on using hashes here.

File details

Details for the file bmb_json-0.2.0-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for bmb_json-0.2.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c6ca39629535fc18afcbc0d19d104b648e7d0f1149ad22f139784d7ee1e14d0a
MD5 8675e5d930c4ed2646762ed1d4e01800
BLAKE2b-256 0a7295e1bf8aedb9e1265f10ee0ea848fb08ce733e38b13e52c923fa3588e34c

See more details on using hashes here.

File details

Details for the file bmb_json-0.2.0-py3-none-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for bmb_json-0.2.0-py3-none-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 a9c7169cd9bd974e92db2e3f00a25e8b9da673d65a2341d6f1463121d5720e44
MD5 b596be1fe958e9b25ba31fb965c3ed08
BLAKE2b-256 e5beb86cde00632ae2aac95196760fae9cac149674ceb5904011e931e2e25313

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