jsonyx 2.2.0__tar.gz → 2.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {jsonyx-2.2.0/src/jsonyx.egg-info → jsonyx-2.2.1}/PKG-INFO +20 -20
- {jsonyx-2.2.0 → jsonyx-2.2.1}/README.md +75 -75
- {jsonyx-2.2.0 → jsonyx-2.2.1}/setup.py +54 -54
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/__init__.py +2 -2
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/__main__.py +2 -1
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/_decoder.py +5 -1
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/_encoder.py +9 -11
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/_speedups.c +2260 -2255
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_dumps.py +682 -682
- {jsonyx-2.2.0 → jsonyx-2.2.1/src/jsonyx.egg-info}/PKG-INFO +20 -20
- {jsonyx-2.2.0 → jsonyx-2.2.1}/LICENSE +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/setup.cfg +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/_differ.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/_manipulator.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/allow.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/py.typed +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/__init__.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/conftest.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_apply_filter.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_apply_patch.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_dump.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_jsonyx.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_load_query_value.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_loads.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_make_patch.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_paste_values.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_select_nodes.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_syntax_error.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx/test/test_write.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx.egg-info/SOURCES.txt +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx.egg-info/dependency_links.txt +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx.egg-info/entry_points.txt +0 -0
- {jsonyx-2.2.0 → jsonyx-2.2.1}/src/jsonyx.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jsonyx
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Customizable JSON library for Python
|
|
5
5
|
Author: Nice Zombies
|
|
6
6
|
Author-email: nineteendo19d0@gmail.com
|
|
@@ -88,31 +88,31 @@ The documentation for `jsonyx` is available online at: https://jsonyx.readthedoc
|
|
|
88
88
|
```
|
|
89
89
|
- Dedicated functions for reading and writing files and pretty printing
|
|
90
90
|
|
|
91
|
-
## Benchmark (
|
|
91
|
+
## Benchmark (Apr 20, 2025)
|
|
92
92
|
|
|
93
93
|
We recommend to use [`orjson`](https://pypi.org/project/orjson),
|
|
94
94
|
[`msgspec`](https://pypi.org/project/msgspec) or
|
|
95
95
|
[`pysimdjson`](https://pypi.org/project/pysimdjson) for performance critical
|
|
96
96
|
applications:
|
|
97
97
|
|
|
98
|
-
| encode | json | jsonyx | msgspec |
|
|
99
|
-
|
|
100
|
-
| List of 256 booleans | 4.
|
|
101
|
-
| List of 256 ASCII strings |
|
|
102
|
-
| List of 256 floats |
|
|
103
|
-
| List of 256 dicts with 1 int | 11.10x |
|
|
104
|
-
| Medium complex object | 10.
|
|
105
|
-
| List of 256 strings |
|
|
106
|
-
| Complex object | 7.
|
|
107
|
-
| Dict with 256 lists of 256 dicts with 1 int | 9.
|
|
98
|
+
| encode | json | jsonyx | msgspec | orjson | fastest time |
|
|
99
|
+
|:--------------------------------------------|-------:|-------:|--------:|-------:|-------------:|
|
|
100
|
+
| List of 256 booleans | 4.54x | 4.06x | 1.04x | 1.00x | 1.85 μs |
|
|
101
|
+
| List of 256 ASCII strings | 11.76x | 10.42x | 1.33x | 1.00x | 4.34 μs |
|
|
102
|
+
| List of 256 floats | 24.82x | 25.10x | 1.30x | 1.00x | 8.09 μs |
|
|
103
|
+
| List of 256 dicts with 1 int | 11.10x | 11.50x | 1.34x | 1.00x | 7.92 μs |
|
|
104
|
+
| Medium complex object | 10.25x | 11.05x | 1.14x | 1.00x | 13.77 μs |
|
|
105
|
+
| List of 256 strings | 22.19x | 17.00x | 1.86x | 1.00x | 15.81 μs |
|
|
106
|
+
| Complex object | 7.54x | 7.41x | 1.00x | DNF | 215.37 μs |
|
|
107
|
+
| Dict with 256 lists of 256 dicts with 1 int | 9.34x | 9.74x | 1.29x | 1.00x | 2394.91 μs |
|
|
108
108
|
|
|
109
109
|
| decode | json | jsonyx | msgspec | orjson | simdjson | fastest time |
|
|
110
110
|
|:--------------------------------------------|-------:|-------:|--------:|-------:|---------:|-------------:|
|
|
111
|
-
| List of 256 booleans | 4.
|
|
112
|
-
| List of 256 ASCII strings |
|
|
113
|
-
| List of 256 floats | 10.
|
|
114
|
-
| List of 256 dicts with 1 int | 12.
|
|
115
|
-
| Medium complex object | 12.
|
|
116
|
-
| List of 256 strings |
|
|
117
|
-
| Complex object |
|
|
118
|
-
| Dict with 256 lists of 256 dicts with 1 int | 17.
|
|
111
|
+
| List of 256 booleans | 4.36x | 5.26x | 2.76x | 1.40x | 1.00x | 1.46 μs |
|
|
112
|
+
| List of 256 ASCII strings | 8.54x | 6.93x | 4.28x | 3.96x | 1.00x | 3.46 μs |
|
|
113
|
+
| List of 256 floats | 10.85x | 11.25x | 2.23x | 1.74x | 1.00x | 6.05 μs |
|
|
114
|
+
| List of 256 dicts with 1 int | 12.79x | 11.43x | 7.12x | 5.19x | 1.00x | 6.12 μs |
|
|
115
|
+
| Medium complex object | 12.70x | 12.01x | 5.16x | 4.60x | 1.00x | 7.98 μs |
|
|
116
|
+
| List of 256 strings | 7.11x | 3.82x | 9.70x | 7.80x | 1.00x | 16.52 μs |
|
|
117
|
+
| Complex object | 9.87x | 7.74x | 8.90x | 7.94x | 1.00x | 130.28 μs |
|
|
118
|
+
| Dict with 256 lists of 256 dicts with 1 int | 17.84x | 15.18x | 12.08x | 10.32x | 1.00x | 1674.28 μs |
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
# jsonyx
|
|
2
|
-
|
|
3
|
-
[](http://pypi.org/project/jsonyx)
|
|
4
|
-
[](https://anaconda.org/conda-forge/jsonyx)
|
|
5
|
-
[](http://pypi.org/project/jsonyx)
|
|
6
|
-
[](http://pypi.org/project/jsonyx)
|
|
7
|
-
[](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml)
|
|
8
|
-
[](https://jsonyx.readthedocs.io/en/stable/?badge=stable)
|
|
9
|
-
[](http://pypi.org/project/jsonyx)
|
|
10
|
-
|
|
11
|
-
`jsonyx` is a customizable [JSON](http://json.org) library for Python 3.8+. It
|
|
12
|
-
is written in pure Python with an optional C extension for better performance
|
|
13
|
-
and no dependencies.
|
|
14
|
-
|
|
15
|
-
The documentation for `jsonyx` is available online at: https://jsonyx.readthedocs.io
|
|
16
|
-
|
|
17
|
-
## Key Features
|
|
18
|
-
|
|
19
|
-
- JSON decoding, encoding and patching
|
|
20
|
-
- Pretty printing:
|
|
21
|
-
```json
|
|
22
|
-
{
|
|
23
|
-
"foo": [1, 2, 3],
|
|
24
|
-
"bar": {"a": 1, "b": 2, "c": 3}
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
- Optionally supports these JSON deviations (specified in the documentation):
|
|
28
|
-
```javascript
|
|
29
|
-
{
|
|
30
|
-
/* Block */ // and line comments
|
|
31
|
-
"Missing commas": [1 2 3],
|
|
32
|
-
"NaN and infinity": [NaN, Infinity, -Infinity],
|
|
33
|
-
"Surrogates": "\ud800",
|
|
34
|
-
"Trailing comma": [0,],
|
|
35
|
-
"Unquoted keys": {key: "value"}
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
- Detailed error messages:
|
|
39
|
-
```none
|
|
40
|
-
Traceback (most recent call last):
|
|
41
|
-
File "/Users/wannes/Downloads/broken.json", line 1, column 99-381
|
|
42
|
-
...sList": {"GlossEntry": {"ID": "SGM..."GML", "XML"]}, "GlossSee": "markup"
|
|
43
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
44
|
-
jsonyx.JSONSyntaxError: Unterminated object
|
|
45
|
-
```
|
|
46
|
-
- Dedicated functions for reading and writing files and pretty printing
|
|
47
|
-
|
|
48
|
-
## Benchmark (
|
|
49
|
-
|
|
50
|
-
We recommend to use [`orjson`](https://pypi.org/project/orjson),
|
|
51
|
-
[`msgspec`](https://pypi.org/project/msgspec) or
|
|
52
|
-
[`pysimdjson`](https://pypi.org/project/pysimdjson) for performance critical
|
|
53
|
-
applications:
|
|
54
|
-
|
|
55
|
-
| encode | json | jsonyx | msgspec |
|
|
56
|
-
|
|
57
|
-
| List of 256 booleans | 4.
|
|
58
|
-
| List of 256 ASCII strings |
|
|
59
|
-
| List of 256 floats |
|
|
60
|
-
| List of 256 dicts with 1 int | 11.10x |
|
|
61
|
-
| Medium complex object | 10.
|
|
62
|
-
| List of 256 strings |
|
|
63
|
-
| Complex object | 7.
|
|
64
|
-
| Dict with 256 lists of 256 dicts with 1 int | 9.
|
|
65
|
-
|
|
66
|
-
| decode | json | jsonyx | msgspec | orjson | simdjson | fastest time |
|
|
67
|
-
|:--------------------------------------------|-------:|-------:|--------:|-------:|---------:|-------------:|
|
|
68
|
-
| List of 256 booleans | 4.
|
|
69
|
-
| List of 256 ASCII strings |
|
|
70
|
-
| List of 256 floats | 10.
|
|
71
|
-
| List of 256 dicts with 1 int | 12.
|
|
72
|
-
| Medium complex object | 12.
|
|
73
|
-
| List of 256 strings |
|
|
74
|
-
| Complex object |
|
|
75
|
-
| Dict with 256 lists of 256 dicts with 1 int | 17.
|
|
1
|
+
# jsonyx
|
|
2
|
+
|
|
3
|
+
[](http://pypi.org/project/jsonyx)
|
|
4
|
+
[](https://anaconda.org/conda-forge/jsonyx)
|
|
5
|
+
[](http://pypi.org/project/jsonyx)
|
|
6
|
+
[](http://pypi.org/project/jsonyx)
|
|
7
|
+
[](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml)
|
|
8
|
+
[](https://jsonyx.readthedocs.io/en/stable/?badge=stable)
|
|
9
|
+
[](http://pypi.org/project/jsonyx)
|
|
10
|
+
|
|
11
|
+
`jsonyx` is a customizable [JSON](http://json.org) library for Python 3.8+. It
|
|
12
|
+
is written in pure Python with an optional C extension for better performance
|
|
13
|
+
and no dependencies.
|
|
14
|
+
|
|
15
|
+
The documentation for `jsonyx` is available online at: https://jsonyx.readthedocs.io
|
|
16
|
+
|
|
17
|
+
## Key Features
|
|
18
|
+
|
|
19
|
+
- JSON decoding, encoding and patching
|
|
20
|
+
- Pretty printing:
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"foo": [1, 2, 3],
|
|
24
|
+
"bar": {"a": 1, "b": 2, "c": 3}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
- Optionally supports these JSON deviations (specified in the documentation):
|
|
28
|
+
```javascript
|
|
29
|
+
{
|
|
30
|
+
/* Block */ // and line comments
|
|
31
|
+
"Missing commas": [1 2 3],
|
|
32
|
+
"NaN and infinity": [NaN, Infinity, -Infinity],
|
|
33
|
+
"Surrogates": "\ud800",
|
|
34
|
+
"Trailing comma": [0,],
|
|
35
|
+
"Unquoted keys": {key: "value"}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
- Detailed error messages:
|
|
39
|
+
```none
|
|
40
|
+
Traceback (most recent call last):
|
|
41
|
+
File "/Users/wannes/Downloads/broken.json", line 1, column 99-381
|
|
42
|
+
...sList": {"GlossEntry": {"ID": "SGM..."GML", "XML"]}, "GlossSee": "markup"
|
|
43
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
44
|
+
jsonyx.JSONSyntaxError: Unterminated object
|
|
45
|
+
```
|
|
46
|
+
- Dedicated functions for reading and writing files and pretty printing
|
|
47
|
+
|
|
48
|
+
## Benchmark (Apr 20, 2025)
|
|
49
|
+
|
|
50
|
+
We recommend to use [`orjson`](https://pypi.org/project/orjson),
|
|
51
|
+
[`msgspec`](https://pypi.org/project/msgspec) or
|
|
52
|
+
[`pysimdjson`](https://pypi.org/project/pysimdjson) for performance critical
|
|
53
|
+
applications:
|
|
54
|
+
|
|
55
|
+
| encode | json | jsonyx | msgspec | orjson | fastest time |
|
|
56
|
+
|:--------------------------------------------|-------:|-------:|--------:|-------:|-------------:|
|
|
57
|
+
| List of 256 booleans | 4.54x | 4.06x | 1.04x | 1.00x | 1.85 μs |
|
|
58
|
+
| List of 256 ASCII strings | 11.76x | 10.42x | 1.33x | 1.00x | 4.34 μs |
|
|
59
|
+
| List of 256 floats | 24.82x | 25.10x | 1.30x | 1.00x | 8.09 μs |
|
|
60
|
+
| List of 256 dicts with 1 int | 11.10x | 11.50x | 1.34x | 1.00x | 7.92 μs |
|
|
61
|
+
| Medium complex object | 10.25x | 11.05x | 1.14x | 1.00x | 13.77 μs |
|
|
62
|
+
| List of 256 strings | 22.19x | 17.00x | 1.86x | 1.00x | 15.81 μs |
|
|
63
|
+
| Complex object | 7.54x | 7.41x | 1.00x | DNF | 215.37 μs |
|
|
64
|
+
| Dict with 256 lists of 256 dicts with 1 int | 9.34x | 9.74x | 1.29x | 1.00x | 2394.91 μs |
|
|
65
|
+
|
|
66
|
+
| decode | json | jsonyx | msgspec | orjson | simdjson | fastest time |
|
|
67
|
+
|:--------------------------------------------|-------:|-------:|--------:|-------:|---------:|-------------:|
|
|
68
|
+
| List of 256 booleans | 4.36x | 5.26x | 2.76x | 1.40x | 1.00x | 1.46 μs |
|
|
69
|
+
| List of 256 ASCII strings | 8.54x | 6.93x | 4.28x | 3.96x | 1.00x | 3.46 μs |
|
|
70
|
+
| List of 256 floats | 10.85x | 11.25x | 2.23x | 1.74x | 1.00x | 6.05 μs |
|
|
71
|
+
| List of 256 dicts with 1 int | 12.79x | 11.43x | 7.12x | 5.19x | 1.00x | 6.12 μs |
|
|
72
|
+
| Medium complex object | 12.70x | 12.01x | 5.16x | 4.60x | 1.00x | 7.98 μs |
|
|
73
|
+
| List of 256 strings | 7.11x | 3.82x | 9.70x | 7.80x | 1.00x | 16.52 μs |
|
|
74
|
+
| Complex object | 9.87x | 7.74x | 8.90x | 7.94x | 1.00x | 130.28 μs |
|
|
75
|
+
| Dict with 256 lists of 256 dicts with 1 int | 17.84x | 15.18x | 12.08x | 10.32x | 1.00x | 1674.28 μs |
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
"""jsonyx setup."""
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
|
|
4
|
-
__all__: list[str] = []
|
|
5
|
-
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
|
|
8
|
-
# pylint: disable-next=E0401
|
|
9
|
-
from setuptools import Extension, setup # type: ignore
|
|
10
|
-
|
|
11
|
-
if __name__ == "__main__":
|
|
12
|
-
setup(
|
|
13
|
-
name="jsonyx",
|
|
14
|
-
version="2.2.
|
|
15
|
-
description="Customizable JSON library for Python",
|
|
16
|
-
long_description=Path("README.md").read_text(encoding="utf-8"),
|
|
17
|
-
long_description_content_type="text/markdown",
|
|
18
|
-
author="Nice Zombies",
|
|
19
|
-
author_email="nineteendo19d0@gmail.com",
|
|
20
|
-
maintainer="Nice Zombies",
|
|
21
|
-
maintainer_email="nineteendo19d0@gmail.com",
|
|
22
|
-
packages=["jsonyx", "jsonyx.test"],
|
|
23
|
-
ext_modules=[
|
|
24
|
-
Extension("_jsonyx", ["src/jsonyx/_speedups.c"], optional=True),
|
|
25
|
-
],
|
|
26
|
-
classifiers=[
|
|
27
|
-
"Development Status :: 5 - Production/Stable",
|
|
28
|
-
"Intended Audience :: Developers",
|
|
29
|
-
"Operating System :: OS Independent",
|
|
30
|
-
"Programming Language :: Python :: 3 :: Only",
|
|
31
|
-
"Programming Language :: Python :: 3.8",
|
|
32
|
-
"Programming Language :: Python :: 3.9",
|
|
33
|
-
"Programming Language :: Python :: 3.10",
|
|
34
|
-
"Programming Language :: Python :: 3.11",
|
|
35
|
-
"Programming Language :: Python :: 3.12",
|
|
36
|
-
"Programming Language :: Python :: 3.13",
|
|
37
|
-
"Programming Language :: Python :: 3.14",
|
|
38
|
-
],
|
|
39
|
-
license="GPL-3.0",
|
|
40
|
-
keywords=["python", "json", "json-parser"],
|
|
41
|
-
package_dir={"": "src"},
|
|
42
|
-
# setuptools arguments
|
|
43
|
-
entry_points={"console_scripts": ["jsonyx = jsonyx.__main__:main"]},
|
|
44
|
-
python_requires=">=3.8",
|
|
45
|
-
project_urls={
|
|
46
|
-
"Homepage": "https://github.com/nineteendo/jsonyx",
|
|
47
|
-
"Changelog": (
|
|
48
|
-
"https://jsonyx.readthedocs.io/en/latest/changelog.html"
|
|
49
|
-
),
|
|
50
|
-
"Documentation": "https://jsonyx.readthedocs.io",
|
|
51
|
-
"Issues": "https://github.com/nineteendo/jsonyx/issues",
|
|
52
|
-
"Sponser": "https://paypal.me/nineteendo",
|
|
53
|
-
},
|
|
54
|
-
)
|
|
1
|
+
"""jsonyx setup."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
__all__: list[str] = []
|
|
5
|
+
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
# pylint: disable-next=E0401
|
|
9
|
+
from setuptools import Extension, setup # type: ignore
|
|
10
|
+
|
|
11
|
+
if __name__ == "__main__":
|
|
12
|
+
setup(
|
|
13
|
+
name="jsonyx",
|
|
14
|
+
version="2.2.1",
|
|
15
|
+
description="Customizable JSON library for Python",
|
|
16
|
+
long_description=Path("README.md").read_text(encoding="utf-8"),
|
|
17
|
+
long_description_content_type="text/markdown",
|
|
18
|
+
author="Nice Zombies",
|
|
19
|
+
author_email="nineteendo19d0@gmail.com",
|
|
20
|
+
maintainer="Nice Zombies",
|
|
21
|
+
maintainer_email="nineteendo19d0@gmail.com",
|
|
22
|
+
packages=["jsonyx", "jsonyx.test"],
|
|
23
|
+
ext_modules=[
|
|
24
|
+
Extension("_jsonyx", ["src/jsonyx/_speedups.c"], optional=True),
|
|
25
|
+
],
|
|
26
|
+
classifiers=[
|
|
27
|
+
"Development Status :: 5 - Production/Stable",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
29
|
+
"Operating System :: OS Independent",
|
|
30
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
31
|
+
"Programming Language :: Python :: 3.8",
|
|
32
|
+
"Programming Language :: Python :: 3.9",
|
|
33
|
+
"Programming Language :: Python :: 3.10",
|
|
34
|
+
"Programming Language :: Python :: 3.11",
|
|
35
|
+
"Programming Language :: Python :: 3.12",
|
|
36
|
+
"Programming Language :: Python :: 3.13",
|
|
37
|
+
"Programming Language :: Python :: 3.14",
|
|
38
|
+
],
|
|
39
|
+
license="GPL-3.0",
|
|
40
|
+
keywords=["python", "json", "json-parser"],
|
|
41
|
+
package_dir={"": "src"},
|
|
42
|
+
# setuptools arguments
|
|
43
|
+
entry_points={"console_scripts": ["jsonyx = jsonyx.__main__:main"]},
|
|
44
|
+
python_requires=">=3.8",
|
|
45
|
+
project_urls={
|
|
46
|
+
"Homepage": "https://github.com/nineteendo/jsonyx",
|
|
47
|
+
"Changelog": (
|
|
48
|
+
"https://jsonyx.readthedocs.io/en/latest/changelog.html"
|
|
49
|
+
),
|
|
50
|
+
"Documentation": "https://jsonyx.readthedocs.io",
|
|
51
|
+
"Issues": "https://github.com/nineteendo/jsonyx/issues",
|
|
52
|
+
"Sponser": "https://paypal.me/nineteendo",
|
|
53
|
+
},
|
|
54
|
+
)
|
|
@@ -21,7 +21,7 @@ __all__: list[str] = [
|
|
|
21
21
|
"select_nodes",
|
|
22
22
|
"write",
|
|
23
23
|
]
|
|
24
|
-
__version__: str = "2.2.
|
|
24
|
+
__version__: str = "2.2.1"
|
|
25
25
|
|
|
26
26
|
from typing import TYPE_CHECKING, Any, Protocol, TypeVar
|
|
27
27
|
|
|
@@ -135,7 +135,7 @@ def read(
|
|
|
135
135
|
>>> with TemporaryDirectory() as tmpdir:
|
|
136
136
|
... filename = Path(tmpdir) / "file.json"
|
|
137
137
|
... _ = filename.write_text('["filesystem API"]', "utf-8")
|
|
138
|
-
... json.
|
|
138
|
+
... json.read(filename)
|
|
139
139
|
...
|
|
140
140
|
['filesystem API']
|
|
141
141
|
|
|
@@ -242,7 +242,8 @@ def _run(args: _Namespace) -> None:
|
|
|
242
242
|
stderr.write("".join(format_syntax_error(exc)))
|
|
243
243
|
sys.exit(1)
|
|
244
244
|
except (
|
|
245
|
-
AssertionError, LookupError, RecursionError, TypeError,
|
|
245
|
+
AssertionError, LookupError, OSError, RecursionError, TypeError,
|
|
246
|
+
ValueError,
|
|
246
247
|
) as exc:
|
|
247
248
|
stderr.write("".join(format_exception_only(None, exc)))
|
|
248
249
|
sys.exit(1)
|
|
@@ -126,6 +126,8 @@ def _unescape_unicode(filename: str, s: str, end: int) -> int:
|
|
|
126
126
|
class TruncatedSyntaxError(SyntaxError):
|
|
127
127
|
"""Truncated syntax error.
|
|
128
128
|
|
|
129
|
+
.. versionadded:: 2.0
|
|
130
|
+
|
|
129
131
|
:param msg: an error message
|
|
130
132
|
:param filename: the path to the file
|
|
131
133
|
:param doc: a string
|
|
@@ -262,6 +264,7 @@ def detect_encoding(b: bytes) -> str:
|
|
|
262
264
|
# XX 00 XX -- - utf-16-le
|
|
263
265
|
encoding = "utf-16-le" if b[2] or b[3] else "utf-32-le"
|
|
264
266
|
elif len(b) == 2:
|
|
267
|
+
# check for cut off json
|
|
265
268
|
if not b[0]:
|
|
266
269
|
# 00 -- - utf-16-be
|
|
267
270
|
encoding = "utf-16-be"
|
|
@@ -679,10 +682,11 @@ class Decoder:
|
|
|
679
682
|
>>> import jsonyx as json
|
|
680
683
|
>>> from pathlib import Path
|
|
681
684
|
>>> from tempfile import TemporaryDirectory
|
|
685
|
+
>>> decoder = json.Decoder()
|
|
682
686
|
>>> with TemporaryDirectory() as tmpdir:
|
|
683
687
|
... filename = Path(tmpdir) / "file.json"
|
|
684
688
|
... _ = filename.write_text('["filesystem API"]', "utf-8")
|
|
685
|
-
...
|
|
689
|
+
... decoder.read(filename)
|
|
686
690
|
...
|
|
687
691
|
['filesystem API']
|
|
688
692
|
|
|
@@ -220,22 +220,20 @@ except ImportError:
|
|
|
220
220
|
first: bool = True
|
|
221
221
|
items: ItemsView[object, object] = mapping.items()
|
|
222
222
|
for key, value in sorted(items) if sort_keys else items:
|
|
223
|
-
|
|
224
|
-
if isinstance(
|
|
225
|
-
s = str(
|
|
223
|
+
key = hook(key) # noqa: PLW2901
|
|
224
|
+
if isinstance(key, (str, str_types)):
|
|
225
|
+
s = str(key)
|
|
226
226
|
else:
|
|
227
|
-
if
|
|
227
|
+
if key is None:
|
|
228
228
|
s = "null"
|
|
229
|
-
elif isinstance(
|
|
230
|
-
s = "true" if
|
|
231
|
-
elif isinstance(
|
|
232
|
-
|
|
233
|
-
)):
|
|
234
|
-
s = encode_float(new_key) # type: ignore
|
|
229
|
+
elif isinstance(key, (bool, bool_types)):
|
|
230
|
+
s = "true" if key else "false"
|
|
231
|
+
elif isinstance(key, (float, int, float_types, int_types)):
|
|
232
|
+
s = encode_float(key) # type: ignore
|
|
235
233
|
elif skipkeys:
|
|
236
234
|
continue
|
|
237
235
|
else:
|
|
238
|
-
msg = f"Keys must be str, not {type(
|
|
236
|
+
msg = f"Keys must be str, not {type(key).__name__}"
|
|
239
237
|
raise TypeError(msg)
|
|
240
238
|
|
|
241
239
|
if not allow_non_str_keys:
|