|
1 | 1 | # jiter |
2 | 2 |
|
| 3 | +[](https://github.com/pydantic/jiter/actions?query=event%3Apush+branch%3Amain+workflow%3ACI) |
| 4 | +[](https://pypi.python.org/pypi/jiter) |
| 5 | +[](https://github.com/pydantic/jiter) |
| 6 | +[](https://github.com/pydantic/jiter/blob/main/LICENSE) |
| 7 | + |
3 | 8 | 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`. |
4 | 9 |
|
5 | 10 | The API is extremely minimal: |
6 | 11 |
|
7 | 12 | ```python |
8 | 13 | def from_json( |
9 | | - data: bytes, |
| 14 | + json_data: bytes, |
| 15 | + /, |
10 | 16 | *, |
11 | 17 | allow_inf_nan: bool = True, |
12 | | - cache_strings: Literal[True, False, 'all', 'keys', 'none'] = True, |
| 18 | + cache_strings: Literal[True, False, "all", "keys", "none"] = True, |
13 | 19 | allow_partial: bool = False, |
14 | 20 | catch_duplicate_keys: bool = False, |
15 | 21 | ) -> Any: |
16 | 22 | """ |
17 | | - Parse input bytes into a JSON string. |
18 | | -
|
19 | | - allow_inf_nan: if True, to allow Infinity and NaN as values in the JSON |
20 | | - cache_strings: cache Python strings to improve performance at the cost of some memory usage |
21 | | - - True / 'all' - cache all strings |
22 | | - - 'keys' - cache only object keys |
23 | | - - 'none' - cache nothing |
24 | | - allow_partial: if True, return parsed content when reaching EOF without closing objects and arrays |
25 | | - catch_duplicate_keys: if True, raise an exception if objects contain the same key multiple times |
| 23 | + Parse input bytes into a JSON object. |
| 24 | +
|
| 25 | + Arguments: |
| 26 | + json_data: The JSON data to parse |
| 27 | + allow_inf_nan: Whether to allow infinity (`Infinity` an `-Infinity`) and `NaN` values to float fields. |
| 28 | + Defaults to True. |
| 29 | + cache_strings: cache Python strings to improve performance at the cost of some memory usage |
| 30 | + - True / 'all' - cache all strings |
| 31 | + - 'keys' - cache only object keys |
| 32 | + - False / 'none' - cache nothing |
| 33 | + allow_partial: if True, return parsed content when reaching EOF without closing objects and arrays |
| 34 | + catch_duplicate_keys: if True, raise an exception if objects contain the same key multiple times |
| 35 | +
|
| 36 | + Returns: |
| 37 | + Python object built from the JSON input. |
26 | 38 | """ |
27 | | - ... |
28 | 39 |
|
29 | 40 | def cache_clear() -> None: |
30 | | - """Clear the string cache""" |
31 | | - ... |
| 41 | + """ |
| 42 | + Reset the string cache. |
| 43 | + """ |
32 | 44 |
|
33 | 45 | def cache_usage() -> int: |
34 | | - """Get number of strings in the cache""" |
35 | | - ... |
| 46 | + """ |
| 47 | + get the size of the string cache. |
| 48 | +
|
| 49 | + Returns: |
| 50 | + Size of the string cache in bytes. |
| 51 | + """ |
36 | 52 | ``` |
0 commit comments