jsonyx 2.2.0__tar.gz → 2.3.0__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.3.0}/PKG-INFO +118 -118
- {jsonyx-2.2.0 → jsonyx-2.3.0}/README.md +22 -22
- {jsonyx-2.2.0 → jsonyx-2.3.0}/setup.cfg +4 -4
- {jsonyx-2.2.0 → jsonyx-2.3.0}/setup.py +54 -54
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/__init__.py +3 -3
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/__main__.py +2 -1
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/_decoder.py +19 -13
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/_differ.py +4 -4
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/_encoder.py +10 -12
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/_speedups.c +2265 -2255
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_dumps.py +682 -682
- {jsonyx-2.2.0 → jsonyx-2.3.0/src/jsonyx.egg-info}/PKG-INFO +118 -118
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx.egg-info/SOURCES.txt +0 -1
- {jsonyx-2.2.0 → jsonyx-2.3.0}/LICENSE +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/_manipulator.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/allow.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/py.typed +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/__init__.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/conftest.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_apply_filter.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_apply_patch.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_dump.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_jsonyx.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_load_query_value.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_loads.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_make_patch.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_paste_values.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_select_nodes.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_syntax_error.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_write.py +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx.egg-info/dependency_links.txt +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx.egg-info/entry_points.txt +0 -0
- {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx.egg-info/top_level.txt +0 -0
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: jsonyx
|
|
3
|
-
Version: 2.
|
|
4
|
-
Summary: Customizable JSON library for Python
|
|
5
|
-
Author: Nice Zombies
|
|
6
|
-
Author-email: nineteendo19d0@gmail.com
|
|
7
|
-
Maintainer: Nice Zombies
|
|
8
|
-
Maintainer-email: nineteendo19d0@gmail.com
|
|
9
|
-
License: GPL-3.0
|
|
10
|
-
Project-URL: Homepage, https://github.com/nineteendo/jsonyx
|
|
11
|
-
Project-URL: Changelog, https://jsonyx.readthedocs.io/en/latest/changelog.html
|
|
12
|
-
Project-URL: Documentation, https://jsonyx.readthedocs.io
|
|
13
|
-
Project-URL: Issues, https://github.com/nineteendo/jsonyx/issues
|
|
14
|
-
Project-URL: Sponser, https://paypal.me/nineteendo
|
|
15
|
-
Keywords: python,json,json-parser
|
|
16
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
17
|
-
Classifier: Intended Audience :: Developers
|
|
18
|
-
Classifier: Operating System :: OS Independent
|
|
19
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
26
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
27
|
-
Requires-Python: >=3.8
|
|
28
|
-
Description-Content-Type: text/markdown
|
|
29
|
-
License-File: LICENSE
|
|
30
|
-
Dynamic: author
|
|
31
|
-
Dynamic: author-email
|
|
32
|
-
Dynamic: classifier
|
|
33
|
-
Dynamic: description
|
|
34
|
-
Dynamic: description-content-type
|
|
35
|
-
Dynamic: keywords
|
|
36
|
-
Dynamic: license
|
|
37
|
-
Dynamic: license-file
|
|
38
|
-
Dynamic: maintainer
|
|
39
|
-
Dynamic: maintainer-email
|
|
40
|
-
Dynamic: project-url
|
|
41
|
-
Dynamic: requires-python
|
|
42
|
-
Dynamic: summary
|
|
43
|
-
|
|
44
|
-
# jsonyx
|
|
45
|
-
|
|
46
|
-
[](http://pypi.org/project/jsonyx)
|
|
47
|
-
[](https://anaconda.org/conda-forge/jsonyx)
|
|
48
|
-
[](http://pypi.org/project/jsonyx)
|
|
49
|
-
[](http://pypi.org/project/jsonyx)
|
|
50
|
-
[](https://jsonyx.readthedocs.io/en/stable/?badge=stable)
|
|
52
|
-
[](http://pypi.org/project/jsonyx)
|
|
53
|
-
|
|
54
|
-
`jsonyx` is a customizable [JSON](http://json.org) library for Python 3.8+. It
|
|
55
|
-
is written in pure Python with an optional C extension for better performance
|
|
56
|
-
and no dependencies.
|
|
57
|
-
|
|
58
|
-
The documentation for `jsonyx` is available online at: https://jsonyx.readthedocs.io
|
|
59
|
-
|
|
60
|
-
## Key Features
|
|
61
|
-
|
|
62
|
-
- JSON decoding, encoding and patching
|
|
63
|
-
- Pretty printing:
|
|
64
|
-
```json
|
|
65
|
-
{
|
|
66
|
-
"foo": [1, 2, 3],
|
|
67
|
-
"bar": {"a": 1, "b": 2, "c": 3}
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
- Optionally supports these JSON deviations (specified in the documentation):
|
|
71
|
-
```javascript
|
|
72
|
-
{
|
|
73
|
-
/* Block */ // and line comments
|
|
74
|
-
"Missing commas": [1 2 3],
|
|
75
|
-
"NaN and infinity": [NaN, Infinity, -Infinity],
|
|
76
|
-
"Surrogates": "\ud800",
|
|
77
|
-
"Trailing comma": [0,],
|
|
78
|
-
"Unquoted keys": {key: "value"}
|
|
79
|
-
}
|
|
80
|
-
```
|
|
81
|
-
- Detailed error messages:
|
|
82
|
-
```none
|
|
83
|
-
Traceback (most recent call last):
|
|
84
|
-
File "/Users/wannes/Downloads/broken.json", line 1, column 99-381
|
|
85
|
-
...sList": {"GlossEntry": {"ID": "SGM..."GML", "XML"]}, "GlossSee": "markup"
|
|
86
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
87
|
-
jsonyx.JSONSyntaxError: Unterminated object
|
|
88
|
-
```
|
|
89
|
-
- Dedicated functions for reading and writing files and pretty printing
|
|
90
|
-
|
|
91
|
-
## Benchmark (
|
|
92
|
-
|
|
93
|
-
We recommend to use [`orjson`](https://pypi.org/project/orjson),
|
|
94
|
-
[`msgspec`](https://pypi.org/project/msgspec) or
|
|
95
|
-
[`pysimdjson`](https://pypi.org/project/pysimdjson) for performance critical
|
|
96
|
-
applications:
|
|
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.
|
|
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.
|
|
108
|
-
|
|
109
|
-
| decode | json |
|
|
110
|
-
|
|
111
|
-
| List of 256 booleans | 4.
|
|
112
|
-
| List of 256 ASCII strings | 9.
|
|
113
|
-
| List of 256 floats | 10.
|
|
114
|
-
| List of 256 dicts with 1 int | 12.
|
|
115
|
-
| Medium complex object |
|
|
116
|
-
| List of 256 strings |
|
|
117
|
-
| Complex object |
|
|
118
|
-
| Dict with 256 lists of 256 dicts with 1 int |
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jsonyx
|
|
3
|
+
Version: 2.3.0
|
|
4
|
+
Summary: Customizable JSON library for Python
|
|
5
|
+
Author: Nice Zombies
|
|
6
|
+
Author-email: nineteendo19d0@gmail.com
|
|
7
|
+
Maintainer: Nice Zombies
|
|
8
|
+
Maintainer-email: nineteendo19d0@gmail.com
|
|
9
|
+
License: GPL-3.0
|
|
10
|
+
Project-URL: Homepage, https://github.com/nineteendo/jsonyx
|
|
11
|
+
Project-URL: Changelog, https://jsonyx.readthedocs.io/en/latest/changelog.html
|
|
12
|
+
Project-URL: Documentation, https://jsonyx.readthedocs.io
|
|
13
|
+
Project-URL: Issues, https://github.com/nineteendo/jsonyx/issues
|
|
14
|
+
Project-URL: Sponser, https://paypal.me/nineteendo
|
|
15
|
+
Keywords: python,json,json-parser
|
|
16
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
27
|
+
Requires-Python: >=3.8
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Dynamic: author
|
|
31
|
+
Dynamic: author-email
|
|
32
|
+
Dynamic: classifier
|
|
33
|
+
Dynamic: description
|
|
34
|
+
Dynamic: description-content-type
|
|
35
|
+
Dynamic: keywords
|
|
36
|
+
Dynamic: license
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
Dynamic: maintainer
|
|
39
|
+
Dynamic: maintainer-email
|
|
40
|
+
Dynamic: project-url
|
|
41
|
+
Dynamic: requires-python
|
|
42
|
+
Dynamic: summary
|
|
43
|
+
|
|
44
|
+
# jsonyx
|
|
45
|
+
|
|
46
|
+
[](http://pypi.org/project/jsonyx)
|
|
47
|
+
[](https://anaconda.org/conda-forge/jsonyx)
|
|
48
|
+
[](http://pypi.org/project/jsonyx)
|
|
49
|
+
[](http://pypi.org/project/jsonyx)
|
|
50
|
+
[](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml)
|
|
51
|
+
[](https://jsonyx.readthedocs.io/en/stable/?badge=stable)
|
|
52
|
+
[](http://pypi.org/project/jsonyx)
|
|
53
|
+
|
|
54
|
+
`jsonyx` is a customizable [JSON](http://json.org) library for Python 3.8+. It
|
|
55
|
+
is written in pure Python with an optional C extension for better performance
|
|
56
|
+
and no dependencies.
|
|
57
|
+
|
|
58
|
+
The documentation for `jsonyx` is available online at: https://jsonyx.readthedocs.io
|
|
59
|
+
|
|
60
|
+
## Key Features
|
|
61
|
+
|
|
62
|
+
- JSON decoding, encoding and patching
|
|
63
|
+
- Pretty printing:
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"foo": [1, 2, 3],
|
|
67
|
+
"bar": {"a": 1, "b": 2, "c": 3}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
- Optionally supports these JSON deviations (specified in the documentation):
|
|
71
|
+
```javascript
|
|
72
|
+
{
|
|
73
|
+
/* Block */ // and line comments
|
|
74
|
+
"Missing commas": [1 2 3],
|
|
75
|
+
"NaN and infinity": [NaN, Infinity, -Infinity],
|
|
76
|
+
"Surrogates": "\ud800",
|
|
77
|
+
"Trailing comma": [0,],
|
|
78
|
+
"Unquoted keys": {key: "value"}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
- Detailed error messages:
|
|
82
|
+
```none
|
|
83
|
+
Traceback (most recent call last):
|
|
84
|
+
File "/Users/wannes/Downloads/broken.json", line 1, column 99-381
|
|
85
|
+
...sList": {"GlossEntry": {"ID": "SGM..."GML", "XML"]}, "GlossSee": "markup"
|
|
86
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
87
|
+
jsonyx.JSONSyntaxError: Unterminated object
|
|
88
|
+
```
|
|
89
|
+
- Dedicated functions for reading and writing files and pretty printing
|
|
90
|
+
|
|
91
|
+
## Benchmark (Apr 30, 2025)
|
|
92
|
+
|
|
93
|
+
We recommend to use [`orjson`](https://pypi.org/project/orjson),
|
|
94
|
+
[`msgspec`](https://pypi.org/project/msgspec) or
|
|
95
|
+
[`pysimdjson`](https://pypi.org/project/pysimdjson) for performance critical
|
|
96
|
+
applications:
|
|
97
|
+
|
|
98
|
+
| encode | json | jsonyx | msgspec | orjson | fastest time |
|
|
99
|
+
|:--------------------------------------------|-------:|-------:|--------:|-------:|-------------:|
|
|
100
|
+
| List of 256 booleans | 4.62x | 4.17x | 1.06x | 1.00x | 1.82 μs |
|
|
101
|
+
| List of 256 ASCII strings | 14.09x | 8.10x | 1.66x | 1.00x | 3.66 μs |
|
|
102
|
+
| List of 256 floats | 25.20x | 25.18x | 1.33x | 1.00x | 8.07 μs |
|
|
103
|
+
| List of 256 dicts with 1 int | 11.24x | 9.89x | 1.34x | 1.00x | 7.87 μs |
|
|
104
|
+
| Medium complex object | 10.21x | 8.85x | 1.17x | 1.00x | 13.87 μs |
|
|
105
|
+
| List of 256 strings | 26.46x | 15.18x | 2.23x | 1.00x | 13.37 μs |
|
|
106
|
+
| Complex object | 7.86x | 7.41x | 1.00x | DNF | 207.83 μs |
|
|
107
|
+
| Dict with 256 lists of 256 dicts with 1 int | 9.87x | 8.72x | 1.24x | 1.00x | 2295.24 μs |
|
|
108
|
+
|
|
109
|
+
| decode | json | jsonyx | msgspec | orjson | simdjson | fastest time |
|
|
110
|
+
|:--------------------------------------------|-------:|--------:|--------:|-------:|---------:|-------------:|
|
|
111
|
+
| List of 256 booleans | 4.70x | 5.22x | 2.92x | 1.41x | 1.00x | 1.45 μs |
|
|
112
|
+
| List of 256 ASCII strings | 9.04x | 7.05x | 4.85x | 4.43x | 1.00x | 3.15 μs |
|
|
113
|
+
| List of 256 floats | 10.91x | 11.22x | 2.24x | 1.73x | 1.00x | 6.14 μs |
|
|
114
|
+
| List of 256 dicts with 1 int | 12.99x | 11.65x | 7.35x | 5.30x | 1.00x | 6.11 μs |
|
|
115
|
+
| Medium complex object | 13.41x | 12.94x | 5.44x | 4.67x | 1.00x | 7.65 μs |
|
|
116
|
+
| List of 256 strings | 6.85x | 3.75x | 9.56x | 7.85x | 1.00x | 16.78 μs |
|
|
117
|
+
| Complex object | 9.36x | 7.63x | 8.55x | 7.67x | 1.00x | 136.11 μs |
|
|
118
|
+
| Dict with 256 lists of 256 dicts with 1 int | 19.03x | 15.62x | 11.58x | 9.87x | 1.00x | 1640.77 μs |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://anaconda.org/conda-forge/jsonyx)
|
|
5
5
|
[](http://pypi.org/project/jsonyx)
|
|
6
6
|
[](http://pypi.org/project/jsonyx)
|
|
7
|
-
[](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml)
|
|
8
8
|
[](https://jsonyx.readthedocs.io/en/stable/?badge=stable)
|
|
9
9
|
[](http://pypi.org/project/jsonyx)
|
|
10
10
|
|
|
@@ -45,31 +45,31 @@ The documentation for `jsonyx` is available online at: https://jsonyx.readthedoc
|
|
|
45
45
|
```
|
|
46
46
|
- Dedicated functions for reading and writing files and pretty printing
|
|
47
47
|
|
|
48
|
-
## Benchmark (
|
|
48
|
+
## Benchmark (Apr 30, 2025)
|
|
49
49
|
|
|
50
50
|
We recommend to use [`orjson`](https://pypi.org/project/orjson),
|
|
51
51
|
[`msgspec`](https://pypi.org/project/msgspec) or
|
|
52
52
|
[`pysimdjson`](https://pypi.org/project/pysimdjson) for performance critical
|
|
53
53
|
applications:
|
|
54
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.
|
|
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.
|
|
55
|
+
| encode | json | jsonyx | msgspec | orjson | fastest time |
|
|
56
|
+
|:--------------------------------------------|-------:|-------:|--------:|-------:|-------------:|
|
|
57
|
+
| List of 256 booleans | 4.62x | 4.17x | 1.06x | 1.00x | 1.82 μs |
|
|
58
|
+
| List of 256 ASCII strings | 14.09x | 8.10x | 1.66x | 1.00x | 3.66 μs |
|
|
59
|
+
| List of 256 floats | 25.20x | 25.18x | 1.33x | 1.00x | 8.07 μs |
|
|
60
|
+
| List of 256 dicts with 1 int | 11.24x | 9.89x | 1.34x | 1.00x | 7.87 μs |
|
|
61
|
+
| Medium complex object | 10.21x | 8.85x | 1.17x | 1.00x | 13.87 μs |
|
|
62
|
+
| List of 256 strings | 26.46x | 15.18x | 2.23x | 1.00x | 13.37 μs |
|
|
63
|
+
| Complex object | 7.86x | 7.41x | 1.00x | DNF | 207.83 μs |
|
|
64
|
+
| Dict with 256 lists of 256 dicts with 1 int | 9.87x | 8.72x | 1.24x | 1.00x | 2295.24 μs |
|
|
65
65
|
|
|
66
|
-
| decode | json |
|
|
67
|
-
|
|
68
|
-
| List of 256 booleans | 4.
|
|
69
|
-
| List of 256 ASCII strings | 9.
|
|
70
|
-
| List of 256 floats | 10.
|
|
71
|
-
| List of 256 dicts with 1 int | 12.
|
|
72
|
-
| Medium complex object |
|
|
73
|
-
| List of 256 strings |
|
|
74
|
-
| Complex object |
|
|
75
|
-
| Dict with 256 lists of 256 dicts with 1 int |
|
|
66
|
+
| decode | json | jsonyx | msgspec | orjson | simdjson | fastest time |
|
|
67
|
+
|:--------------------------------------------|-------:|--------:|--------:|-------:|---------:|-------------:|
|
|
68
|
+
| List of 256 booleans | 4.70x | 5.22x | 2.92x | 1.41x | 1.00x | 1.45 μs |
|
|
69
|
+
| List of 256 ASCII strings | 9.04x | 7.05x | 4.85x | 4.43x | 1.00x | 3.15 μs |
|
|
70
|
+
| List of 256 floats | 10.91x | 11.22x | 2.24x | 1.73x | 1.00x | 6.14 μs |
|
|
71
|
+
| List of 256 dicts with 1 int | 12.99x | 11.65x | 7.35x | 5.30x | 1.00x | 6.11 μs |
|
|
72
|
+
| Medium complex object | 13.41x | 12.94x | 5.44x | 4.67x | 1.00x | 7.65 μs |
|
|
73
|
+
| List of 256 strings | 6.85x | 3.75x | 9.56x | 7.85x | 1.00x | 16.78 μs |
|
|
74
|
+
| Complex object | 9.36x | 7.63x | 8.55x | 7.67x | 1.00x | 136.11 μs |
|
|
75
|
+
| Dict with 256 lists of 256 dicts with 1 int | 19.03x | 15.62x | 11.58x | 9.87x | 1.00x | 1640.77 μs |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|
|
@@ -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.
|
|
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.3.0",
|
|
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.
|
|
24
|
+
__version__: str = "2.3.0"
|
|
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
|
|
|
@@ -186,7 +186,7 @@ def load(
|
|
|
186
186
|
|
|
187
187
|
|
|
188
188
|
def loads(
|
|
189
|
-
s: bytes | str,
|
|
189
|
+
s: bytearray | bytes | str,
|
|
190
190
|
*,
|
|
191
191
|
allow: Container[str] = NOTHING,
|
|
192
192
|
cache_keys: bool = False,
|
|
@@ -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)
|
|
@@ -124,7 +124,9 @@ def _unescape_unicode(filename: str, s: str, end: int) -> int:
|
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
class TruncatedSyntaxError(SyntaxError):
|
|
127
|
-
"""
|
|
127
|
+
"""Syntax error trucated to fit within the terminal width.
|
|
128
|
+
|
|
129
|
+
.. versionadded:: 2.0
|
|
128
130
|
|
|
129
131
|
:param msg: an error message
|
|
130
132
|
:param filename: the path to the file
|
|
@@ -134,12 +136,17 @@ class TruncatedSyntaxError(SyntaxError):
|
|
|
134
136
|
|
|
135
137
|
Example:
|
|
136
138
|
>>> import jsonyx as json
|
|
137
|
-
>>> raise json.TruncatedSyntaxError(
|
|
139
|
+
>>> raise json.TruncatedSyntaxError(
|
|
140
|
+
... "Invalid number", "<string>", "9" * 5000, 0, 5000
|
|
141
|
+
... )
|
|
138
142
|
Traceback (most recent call last):
|
|
139
|
-
File "<string>", line 1, column
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
jsonyx.TruncatedSyntaxError:
|
|
143
|
+
File "<string>", line 1, column 1-5001
|
|
144
|
+
99999999999999999999999999999999999...9999999999999999999999999999999999
|
|
145
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
146
|
+
jsonyx.TruncatedSyntaxError: Invalid number
|
|
147
|
+
|
|
148
|
+
.. tip:: You can overwrite the width by setting the ``COLUMNS`` environment
|
|
149
|
+
variable.
|
|
143
150
|
|
|
144
151
|
.. seealso:: :func:`jsonyx.format_syntax_error` for formatting the
|
|
145
152
|
exception.
|
|
@@ -213,17 +220,14 @@ TruncatedSyntaxError.__module__ = "jsonyx"
|
|
|
213
220
|
|
|
214
221
|
|
|
215
222
|
class JSONSyntaxError(TruncatedSyntaxError):
|
|
216
|
-
"""Invalid JSON (query) syntax.
|
|
217
|
-
|
|
218
|
-
See :exc:`jsonyx.TruncatedSyntaxError` for more information.
|
|
219
|
-
"""
|
|
223
|
+
"""Invalid JSON (query) syntax."""
|
|
220
224
|
|
|
221
225
|
|
|
222
226
|
JSONSyntaxError.__module__ = "jsonyx"
|
|
223
227
|
_errmsg: type[JSONSyntaxError] = JSONSyntaxError
|
|
224
228
|
|
|
225
229
|
|
|
226
|
-
def detect_encoding(b: bytes) -> str:
|
|
230
|
+
def detect_encoding(b: bytearray | bytes) -> str:
|
|
227
231
|
r"""Detect the JSON encoding.
|
|
228
232
|
|
|
229
233
|
:param b: a JSON string
|
|
@@ -262,6 +266,7 @@ def detect_encoding(b: bytes) -> str:
|
|
|
262
266
|
# XX 00 XX -- - utf-16-le
|
|
263
267
|
encoding = "utf-16-le" if b[2] or b[3] else "utf-32-le"
|
|
264
268
|
elif len(b) == 2:
|
|
269
|
+
# check for cut off json
|
|
265
270
|
if not b[0]:
|
|
266
271
|
# 00 -- - utf-16-be
|
|
267
272
|
encoding = "utf-16-be"
|
|
@@ -679,10 +684,11 @@ class Decoder:
|
|
|
679
684
|
>>> import jsonyx as json
|
|
680
685
|
>>> from pathlib import Path
|
|
681
686
|
>>> from tempfile import TemporaryDirectory
|
|
687
|
+
>>> decoder = json.Decoder()
|
|
682
688
|
>>> with TemporaryDirectory() as tmpdir:
|
|
683
689
|
... filename = Path(tmpdir) / "file.json"
|
|
684
690
|
... _ = filename.write_text('["filesystem API"]', "utf-8")
|
|
685
|
-
...
|
|
691
|
+
... decoder.read(filename)
|
|
686
692
|
...
|
|
687
693
|
['filesystem API']
|
|
688
694
|
|
|
@@ -718,7 +724,7 @@ class Decoder:
|
|
|
718
724
|
return self.loads(fp.read())
|
|
719
725
|
|
|
720
726
|
def loads(
|
|
721
|
-
self, s: bytes | str, *, filename: _StrPath = "<string>",
|
|
727
|
+
self, s: bytearray | bytes | str, *, filename: _StrPath = "<string>",
|
|
722
728
|
) -> Any:
|
|
723
729
|
r"""Deserialize a JSON string to a Python object.
|
|
724
730
|
|
|
@@ -78,16 +78,16 @@ def _make_patch(
|
|
|
78
78
|
if isinstance(old, dict) and isinstance(new, dict):
|
|
79
79
|
old_keys: KeysView[Any] = old.keys() # type: ignore
|
|
80
80
|
new_keys: KeysView[Any] = new.keys() # type: ignore
|
|
81
|
-
for key in old_keys:
|
|
82
|
-
new_path: str = f"{path}{_encode_query_key(key)}"
|
|
81
|
+
for key in old_keys: # type: ignore
|
|
82
|
+
new_path: str = f"{path}{_encode_query_key(key)}" # type: ignore
|
|
83
83
|
if key in new_keys:
|
|
84
84
|
_make_patch(old[key], new[key], patch, new_path)
|
|
85
85
|
else:
|
|
86
86
|
patch.append({"op": "del", "path": new_path})
|
|
87
87
|
|
|
88
|
-
for key in new_keys:
|
|
88
|
+
for key in new_keys: # type: ignore
|
|
89
89
|
if key not in old_keys: # preserve order
|
|
90
|
-
new_path = f"{path}{_encode_query_key(key)}"
|
|
90
|
+
new_path = f"{path}{_encode_query_key(key)}" # type: ignore
|
|
91
91
|
patch.append(
|
|
92
92
|
{"op": "set", "path": new_path, "value": new[key]},
|
|
93
93
|
)
|
|
@@ -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)
|
|
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:
|
|
@@ -287,7 +285,7 @@ except ImportError:
|
|
|
287
285
|
elif isinstance(obj, (str, str_types)):
|
|
288
286
|
write(encode_string(str(obj)))
|
|
289
287
|
elif isinstance(obj, (float, int, float_types, int_types)):
|
|
290
|
-
write(encode_float(obj))
|
|
288
|
+
write(encode_float(obj))
|
|
291
289
|
elif isinstance(obj, (list, tuple, array_types)):
|
|
292
290
|
write_sequence(obj, write, indent_level, current_indent)
|
|
293
291
|
elif isinstance(obj, (dict, object_types)):
|