freshcrate
Home > Frameworks > jiter

jiter

Fast iterable JSON parser.

Description

# jiter [![CI](https://github.com/pydantic/jiter/workflows/CI/badge.svg?event=push)](https://github.com/pydantic/jiter/actions?query=event%3Apush+branch%3Amain+workflow%3ACI) [![pypi](https://img.shields.io/pypi/v/jiter.svg)](https://pypi.python.org/pypi/jiter) [![versions](https://img.shields.io/pypi/pyversions/jiter.svg)](https://github.com/pydantic/jiter) [![license](https://img.shields.io/github/license/pydantic/jiter.svg)](https://github.com/pydantic/jiter/blob/main/LICENSE) This is a standalone version of the JSON parser used in `pydantic-core`. The recommendation is to only use this package directly if you do not use `pydantic`. The API is extremely minimal: ```python def from_json( json_data: bytes, /, *, allow_inf_nan: bool = True, cache_mode: Literal[True, False, 'all', 'keys', 'none'] = 'all', partial_mode: Literal[True, False, 'off', 'on', 'trailing-strings'] = False, catch_duplicate_keys: bool = False, float_mode: Literal['float', 'decimal', 'lossless-float'] = 'float', ) -> Any: """ Parse input bytes into a JSON object. Arguments: json_data: The JSON data to parse allow_inf_nan: Whether to allow infinity (`Infinity` an `-Infinity`) and `NaN` values to float fields. Defaults to True. cache_mode: cache Python strings to improve performance at the cost of some memory usage - True / 'all' - cache all strings - 'keys' - cache only object keys - False / 'none' - cache nothing partial_mode: How to handle incomplete strings: - False / 'off' - raise an exception if the input is incomplete - True / 'on' - allow incomplete JSON but discard the last string if it is incomplete - 'trailing-strings' - allow incomplete JSON, and include the last incomplete string in the output catch_duplicate_keys: if True, raise an exception if objects contain the same key multiple times float_mode: How to return floats: as a `float`, `Decimal` or `LosslessFloat` Returns: Python object built from the JSON input. """ def cache_clear() -> None: """ Reset the string cache. """ def cache_usage() -> int: """ get the size of the string cache. Returns: Size of the string cache in bytes. """ ``` ## Examples The main function provided by Jiter is `from_json()`, which accepts a bytes object containing JSON and returns a Python dictionary, list or other value. ```python import jiter json_data = b'{"name": "John", "age": 30}' parsed_data = jiter.from_json(json_data) print(parsed_data) # Output: {'name': 'John', 'age': 30} ``` ### Handling Partial JSON Incomplete JSON objects can be parsed using the `partial_mode=` parameter. ```python import jiter partial_json = b'{"name": "John", "age": 30, "city": "New Yor' # Raise error on incomplete JSON try: jiter.from_json(partial_json, partial_mode=False) except ValueError as e: print(f'Error: {e}') # Parse incomplete JSON, discarding incomplete last field result = jiter.from_json(partial_json, partial_mode=True) print(result) # Output: {'name': 'John', 'age': 30} # Parse incomplete JSON, including incomplete last field result = jiter.from_json(partial_json, partial_mode='trailing-strings') print(result) # Output: {'name': 'John', 'age': 30, 'city': 'New Yor'} ``` ### Catching Duplicate Keys The `catch_duplicate_keys=True` option can be used to raise a `ValueError` if an object contains duplicate keys. ```python import jiter json_with_dupes = b'{"foo": 1, "foo": 2}' # Default behavior (last value wins) result = jiter.from_json(json_with_dupes) print(result) # Output: {'foo': 2} # Catch duplicate keys try: jiter.from_json(json_with_dupes, catch_duplicate_keys=True) except ValueError as e: print(f'Error: {e}') ```

Release History

VersionChangesUrgencyDate
0.14.0Imported from PyPI (0.14.0)Low4/21/2026
v0.14.0Release v0.14.0Medium4/10/2026
v0.13.0## What's Changed * bump PyO3 to 0.28 by @davidhewitt in https://github.com/pydantic/jiter/pull/233 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.12.0...v0.13.0Low2/2/2026
v0.12.0## What's Changed * chore: pyo3-v0.27.x by @jessekrubin in https://github.com/pydantic/jiter/pull/228 * derive `Default` for enums by @davidhewitt in https://github.com/pydantic/jiter/pull/229 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.11.1...v0.12.0Low11/9/2025
v0.11.1## What's Changed * jiter-python: modify pyproject.toml to include license in wheels by @justeph in https://github.com/pydantic/jiter/pull/222 * refactor: convert all `downcast`s to `cast`s by @jessekrubin in https://github.com/pydantic/jiter/pull/221 * Upgrade GitHub actions/checkout and actions/setup-python by @cclauss in https://github.com/pydantic/jiter/pull/225 * Add GraalPy 3.12 wheels by @msimacek in https://github.com/pydantic/jiter/pull/223 * ci: add builds for windows 11 arm by @dLow10/17/2025
v0.11.0## What's Changed * Impl `std::error::Error` for error types by @friendlymatthew in https://github.com/pydantic/jiter/pull/205 * Set up criterion for benchmarking by @friendlymatthew in https://github.com/pydantic/jiter/pull/197 * Keep strings before incomplete escape sequences in partial mode by @dittos in https://github.com/pydantic/jiter/pull/208 * fix lint reported in Rust 1.89 by @davidhewitt in https://github.com/pydantic/jiter/pull/213 * Build wheels for GraalPy by @msimacek in httpsLow9/15/2025
v0.10.0## What's Changed * Bump pyo3 to 0.25, update supported Python versions by @Viicos in https://github.com/pydantic/jiter/pull/198 * Fix `float_mode` default value in `from_json()` stub definition by @Viicos in https://github.com/pydantic/jiter/pull/199 * replace `cached_py_string` and `pystring_fast_new` with safe alternatives by @davidhewitt in https://github.com/pydantic/jiter/pull/201 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.9.0...v0.10.0Low5/18/2025
v0.9.1Re-release of 0.9.0 built with Rust 1.77 to have a final build working on Windows 7.Low5/18/2025
v0.9.0## What's Changed * Update to a current version of lexical-parse-float by @musicinmybrain in https://github.com/pydantic/jiter/pull/182 * build wheels for emscripten by @davidhewitt in https://github.com/pydantic/jiter/pull/185 * Restore `twine` check by @Viicos in https://github.com/pydantic/jiter/pull/186 * remove `SmallVec` and `LazyIndexMap` from json value by @davidhewitt in https://github.com/pydantic/jiter/pull/184 * bump pyo3 to 0.24 by @davidhewitt in https://github.com/pydantic/jiLow3/10/2025
v0.8.2## What's Changed * fix broken builds by rebuilding with PyO3 0.23.3 by @davidhewitt in https://github.com/pydantic/jiter/pull/180 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.8.1...v0.8.2Low12/3/2024
v0.8.1## What's Changed * ship free-threaded wheel for Windows by @davidhewitt in https://github.com/pydantic/jiter/pull/172 * fix crash on aarch64 linux wheels by @davidhewitt in https://github.com/pydantic/jiter/pull/175 * release: 0.8.1 by @davidhewitt in https://github.com/pydantic/jiter/pull/178 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.8.0...v0.8.1Low12/2/2024
v0.8.0## What's Changed * Upgrade to PyO3 0.23 by @davidhewitt in https://github.com/pydantic/jiter/pull/137 * use `Bound<'py, PyStr>` str equality by @davidhewitt in https://github.com/pydantic/jiter/pull/166 * Fix tests without num-bigint feature by @cjwatson in https://github.com/pydantic/jiter/pull/169 * support free-threaded Python by @davidhewitt in https://github.com/pydantic/jiter/pull/165 * fix linux PGO wheel build by @davidhewitt in https://github.com/pydantic/jiter/pull/170 ## New Low11/26/2024
v0.7.1## What's Changed * Fix `pyo3` as an optional dependency by @cetra3 in https://github.com/pydantic/jiter/pull/160 * ci: simplify jobs, fix coverage by @davidhewitt in https://github.com/pydantic/jiter/pull/161 * update `JsonValue` `allow_partial` to use `PartialMode` by @samuelcolvin in https://github.com/pydantic/jiter/pull/163 ## New Contributors * @cetra3 made their first contribution in https://github.com/pydantic/jiter/pull/160 **Full Changelog**: https://github.com/pydantic/jiterLow11/12/2024
v0.7.0## What's Changed * ci: bump jobs to use 3.13, fixes for ubuntu 24.04 by @davidhewitt in https://github.com/pydantic/jiter/pull/154 * fix: usage of `node12 which is deprecated` in CI by @hamirmahal in https://github.com/pydantic/jiter/pull/153 * ci: fix run-on-arch action (by updating) by @davidhewitt in https://github.com/pydantic/jiter/pull/155 * partial parsing with `JsonValue` by @samuelcolvin in https://github.com/pydantic/jiter/pull/157 ## New Contributors * @hamirmahal made their Low10/31/2024
v0.6.1## What's Changed * Fix `cargo vendor` of jiter crates by @tiran in https://github.com/pydantic/jiter/pull/149 * release: 0.6.1 by @davidhewitt in https://github.com/pydantic/jiter/pull/150 ## New Contributors * @tiran made their first contribution in https://github.com/pydantic/jiter/pull/149 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.6.0...v0.6.1Low10/8/2024
v0.6.0## What's Changed * improve coverage by @samuelcolvin in https://github.com/pydantic/jiter/pull/117 * support `float_mode='decimal'` by @samuelcolvin in https://github.com/pydantic/jiter/pull/116 * fix CI by @samuelcolvin in https://github.com/pydantic/jiter/pull/127 * correct PyO3 feature usage by @davidhewitt in https://github.com/pydantic/jiter/pull/126 * make fuzz checks more lenient by @samuelcolvin in https://github.com/pydantic/jiter/pull/133 * iterative algorithm for take_value by Low10/7/2024
v0.5.0## What's Changed * update to PyO3 0.22 by @davidhewitt in https://github.com/pydantic/jiter/pull/119 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.4.2...v0.5.0Low6/24/2024
v0.4.2## What's Changed * add MSRV of 1.73.0 by @davidhewitt in https://github.com/pydantic/jiter/pull/114 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.4.1...v0.4.2Low6/12/2024
v0.4.1## What's Changed * fix u style unicode strings in python by @samuelcolvin in https://github.com/pydantic/jiter/pull/110 * convert skip to iterate instead of call recursive functions by @davidhewitt in https://github.com/pydantic/jiter/pull/111 ## New Contributors * @sydney-runkle made their first contribution in https://github.com/pydantic/jiter/pull/112 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.4.0...v0.4.1Low5/31/2024
v0.4.0## What's Changed * Fix missing license file in published crate by @musicinmybrain in https://github.com/pydantic/jiter/pull/88 * check duplicate object keys by @samuelcolvin in https://github.com/pydantic/jiter/pull/81 * publish python package by @davidhewitt in https://github.com/pydantic/jiter/pull/93 * release-python: grant oidc permissions by @davidhewitt in https://github.com/pydantic/jiter/pull/94 * attempt to fix test-os by @davidhewitt in https://github.com/pydantic/jiter/pull/95Low5/22/2024
jiter-python-v0.1.0First release of jiter python package.Low5/16/2024
v0.3.0## What's Changed * make `PythonParser` generic around cache mode, not its functions by @samuelcolvin in https://github.com/pydantic/jiter/pull/79 * Switch to using `workspace` for different packages by @samuelcolvin in https://github.com/pydantic/jiter/pull/83 * fix cargo-codspeed in with workspaces in CI by @art049 in https://github.com/pydantic/jiter/pull/85 * Next skip by @samuelcolvin in https://github.com/pydantic/jiter/pull/84 * better debug for `Peek` by @samuelcolvin in https://gitLow4/30/2024
v0.2.1## What's Changed * fix hang when parsing egregiously long integer by @davidhewitt in https://github.com/pydantic/jiter/pull/77 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.2.0...v0.2.1Low4/2/2024
v0.2.0## What's Changed * update to PyO3 0.21 final by @davidhewitt in https://github.com/pydantic/jiter/pull/71 * fast path for ASCII python strings by @samuelcolvin in https://github.com/pydantic/jiter/pull/72 * simd int and string parsing on aarch64 by @samuelcolvin in https://github.com/pydantic/jiter/pull/65 * fix fast string creation for pypy by @samuelcolvin in https://github.com/pydantic/jiter/pull/75 * uprev to 0.2.0 by @samuelcolvin in https://github.com/pydantic/jiter/pull/76 **FuLow4/2/2024
v0.1.1## What's Changed * Support for parsing parial JSON strings in Python by @samuelcolvin in https://github.com/pydantic/jiter/pull/66 * fixed size python string cache by @samuelcolvin in https://github.com/pydantic/jiter/pull/59 * uprev by @samuelcolvin in https://github.com/pydantic/jiter/pull/70 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.1.0...v0.1.1Low3/25/2024
v0.1.0## What's Changed * remove some redundant python reference count ops by @davidhewitt in https://github.com/pydantic/jiter/pull/68 * use `Cow` in `JsonValue` by @samuelcolvin in https://github.com/pydantic/jiter/pull/63 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.0.7...v0.1.0Low3/20/2024
v0.0.7## What's Changed * speedup string parsing by copying serde a little by @samuelcolvin in https://github.com/pydantic/jiter/pull/58 * move from lexical-core to depend on lexical-parse-float directly by @decathorpe in https://github.com/pydantic/jiter/pull/57 * update to PyO3 0.21.0-beta.0 by @davidhewitt in https://github.com/pydantic/jiter/pull/37 ## New Contributors * @decathorpe made their first contribution in https://github.com/pydantic/jiter/pull/57 **Full Changelog**: https://gitLow3/12/2024
v0.0.6## What's Changed * avoid measuring allocation in jiter iter benches by @davidhewitt in https://github.com/pydantic/jiter/pull/46 * Replace `peak` with more efficient `peek` by @davidhewitt in https://github.com/pydantic/jiter/pull/48 * use hashbrown to speedup python string caching by @davidhewitt in https://github.com/pydantic/jiter/pull/51 * fix with python parsing seen on pydantic-core by @samuelcolvin in https://github.com/pydantic/jiter/pull/54 * search the `Vec` for small `LazyIndexMLow1/17/2024
v0.0.5## What's Changed * faster string construction by @samuelcolvin in https://github.com/pydantic/jiter/pull/39 * cache python dict keys by @samuelcolvin in https://github.com/pydantic/jiter/pull/25 * tweak jiter by @samuelcolvin in https://github.com/pydantic/jiter/pull/36 * return a `JsonResult` from `python_parse` by @samuelcolvin in https://github.com/pydantic/jiter/pull/40 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.0.4...v0.0.5Low11/27/2023
v0.0.4## What's Changed * switch to bencher to fix codspeed by @samuelcolvin in https://github.com/pydantic/jiter/pull/32 * make `Parser` private by @samuelcolvin in https://github.com/pydantic/jiter/pull/33 * remove `Cargo.lock` by @samuelcolvin in https://github.com/pydantic/jiter/pull/35 * Support `NaN`, `Infinity` and `-Infinity` by @samuelcolvin in https://github.com/pydantic/jiter/pull/34 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.0.3...v0.0.4Low11/3/2023
v0.0.3## What's Changed * tweak codspeed by @samuelcolvin in https://github.com/pydantic/jiter/pull/28 * revert generic in `JsonValue` by @samuelcolvin in https://github.com/pydantic/jiter/pull/30 * zero as int not float by @samuelcolvin in https://github.com/pydantic/jiter/pull/31 **Full Changelog**: https://github.com/pydantic/jiter/compare/v0.0.2...v0.0.3Low11/2/2023
v0.0.2Release v0.0.2Low11/2/2023

Dependencies & License Audit

Loading dependencies...

Similar Packages

pre-commitA framework for managing and maintaining multi-language pre-commit hooks.v4.6.0
azure-core-tracing-opentelemetryMicrosoft Azure Azure Core OpenTelemetry plugin Library for Pythonazure-template_0.1.0b6187637
spdx-toolsSPDX parser and tools.0.8.5
lacesDjango components that know how to render themselves.0.1.2
django-tasksA backport of Django's built in Tasks framework0.12.0