Skip to main content

O3JSON5

A fast JSON5 parser for Python, written in Rust 🦀

Features

  • Full JSON5 support (comments, trailing commas, unquoted keys, etc.)
  • Simple, Pythonic API
  • Fast performance (up to 100x faster than pure Python implementations)
  • Type hints included

Heavy-lifting done by https://github.com/callum-oakley/json5-rs in Rust.

Installation

pip install o3json5 # or use uv, pdm, poetry, etc. your favorite package manager

Quick Start

import o3json5

# Parse JSON5 with comments and modern features
json5_str = '''{ 
    // Comments are supported!
    name: 'O3JSON5',
    features: [
        'Fast',
        'Simple',
        'Reliable',
    ],
    performance: {
        isFast: true,
        speedRatio: .95, // Decimal points can start with .
    },
}'''

data = o3json5.loads(json5_str)
print(f"Name: {data['name']}")

Benchmarks

O3JSON5 is significantly faster than pure Python JSON5 implementations, approaching native JSON speeds. Click below for detailed benchmarks.

View detailed benchmark results
> python examples/bench.py
Generating test data and running benchmarks...


Benchmarking with approximate 10,000 bytes of data
------------------------------------------------------------
Actual file size: 4,459 bytes
      json: 0.04ms ± 0.01ms
     json5: 40.28ms ± 1.03ms
   o3json5: 0.35ms ± 0.18ms


Benchmarking with approximate 100,000 bytes of data
------------------------------------------------------------
Actual file size: 43,416 bytes
      json: 0.28ms ± 0.02ms
     json5: 383.36ms ± 3.38ms
   o3json5: 2.72ms ± 0.11ms


Benchmarking with approximate 1,000,000 bytes of data
------------------------------------------------------------
Actual file size: 435,373 bytes
      json: 2.94ms ± 0.13ms
     json5: 3870.65ms ± 28.20ms
   o3json5: 28.32ms ± 0.10ms

Note: micro-benchmarks don't say much, and we are already doing JSON5 -> Rust in-memory data structures -> Python in-memory data structures -- while the performance can be further improved, for most use cases, the performance is already good enough.

Reference

Functions

  • loads(s: Union[str, bytes, bytearray]) -> Any

    • Parses a JSON5 string or bytes-like object
    • Raises DecodeError if input is invalid JSON5
    • Raises TypeError if input type is not supported
  • load(fp: Union[str, Path, TextIO]) -> Any

    • Parses JSON5 from a file path or file-like object
    • Accepts string path, Path object, or file-like object
    • Raises DecodeError, TypeError, or OSError

Exceptions

  • DecodeError
    • Subclass of ValueError
    • Raised when JSON5 parsing fails
    • Contains error message with details

Metadata

Release files for o3json5 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for o3json5 0.1.0
File Interpreter ABI Platform Actions
o3json5-0.1.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for o3json5-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
o3json5-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for o3json5-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl

Total release size: 616.7 kB

Release files / o3json5-0.1.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL o3json5-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Size 303.6 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e6274b82cf03e074c4a5b1cf541a5f3d0dad9e17165b746a59f28c3342cede3b
BLAKE2b-256 checksum
How to use checksums
818064b1c88f4fdcca778ceafc161ffc932f058d672a093f2e4bfac8fe5afff8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.0

Release files / o3json5-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl

Download URL o3json5-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 313.0 kB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ad75c25ef50dc8d8dafb10f1f5b0aa245b37fa328497d6cf90443754d499f189
BLAKE2b-256 checksum
How to use checksums
5984faad64ff84fe6fbade8eb11361f72c16ffa5a7734f9ffb556e56d027c963
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.0

Security for o3json5 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page