json-duplicate-keys 2024.12.12__py3-none-any.whl → 2025.6.6__py3-none-any.whl
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.
- json_duplicate_keys/__init__.py +7 -3
- {json_duplicate_keys-2024.12.12.dist-info → json_duplicate_keys-2025.6.6.dist-info}/METADATA +8 -3
- json_duplicate_keys-2025.6.6.dist-info/RECORD +6 -0
- {json_duplicate_keys-2024.12.12.dist-info → json_duplicate_keys-2025.6.6.dist-info}/WHEEL +1 -1
- json_duplicate_keys-2024.12.12.dist-info/RECORD +0 -6
- {json_duplicate_keys-2024.12.12.dist-info → json_duplicate_keys-2025.6.6.dist-info}/LICENSE +0 -0
- {json_duplicate_keys-2024.12.12.dist-info → json_duplicate_keys-2025.6.6.dist-info}/top_level.txt +0 -0
json_duplicate_keys/__init__.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
json_duplicate_keys_VERSION = "2025.6.6"
|
2
3
|
try:
|
3
4
|
unicode # Python 2
|
4
5
|
except NameError:
|
@@ -31,7 +32,7 @@ def normalize_key(name, dupSign_start="{{{", dupSign_end="}}}", _isDebug_=False)
|
|
31
32
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
32
33
|
# # # # # # # # # # # # # # # loads # # # # # # # # # # # # # #
|
33
34
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
34
|
-
def loads(Jstr, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, _isDebug_=False):
|
35
|
+
def loads(Jstr, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, skipDuplicated=False, _isDebug_=False):
|
35
36
|
# User input data type validation
|
36
37
|
if type(_isDebug_) != bool: _isDebug_ = False
|
37
38
|
|
@@ -93,6 +94,9 @@ def loads(Jstr, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, _isD
|
|
93
94
|
Jloads = json.loads(Jstr)
|
94
95
|
if ordered_dict: Jloads = json.loads(Jstr, object_pairs_hook=OrderedDict)
|
95
96
|
|
97
|
+
if skipDuplicated:
|
98
|
+
return JSON_DUPLICATE_KEYS(Jloads)
|
99
|
+
|
96
100
|
if type(Jloads) in [list, dict, OrderedDict]:
|
97
101
|
dupSign_start_escape = "".join(["\\\\u"+hex(ord(c))[2:].zfill(4) for c in dupSign_start])
|
98
102
|
dupSign_start_escape_regex = re.escape(dupSign_start)
|
@@ -147,12 +151,12 @@ def loads(Jstr, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, _isD
|
|
147
151
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
148
152
|
# # # # # # # # # # # # # # # load # # # # # # # # # # # # # #
|
149
153
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
150
|
-
def load(Jfilepath, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, _isDebug_=False):
|
154
|
+
def load(Jfilepath, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, skipDuplicated=False, _isDebug_=False):
|
151
155
|
try:
|
152
156
|
with open(Jfilepath) as Jfile:
|
153
157
|
Jstr = Jfile.read()
|
154
158
|
|
155
|
-
return loads(Jstr, dupSign_start=dupSign_start, dupSign_end=dupSign_end, ordered_dict=ordered_dict, _isDebug_=_isDebug_)
|
159
|
+
return loads(Jstr, dupSign_start=dupSign_start, dupSign_end=dupSign_end, ordered_dict=ordered_dict, skipDuplicated=skipDuplicated, _isDebug_=_isDebug_)
|
156
160
|
except Exception as e:
|
157
161
|
if _isDebug_: print("\x1b[31m[-] ExceptionError: {}\x1b[0m".format(e))
|
158
162
|
return False
|
{json_duplicate_keys-2024.12.12.dist-info → json_duplicate_keys-2025.6.6.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json-duplicate-keys
|
3
|
-
Version:
|
3
|
+
Version: 2025.6.6
|
4
4
|
Summary: Flatten/ Unflatten and Load(s)/ Dump(s) JSON File/ Object with Duplicate Keys
|
5
5
|
Home-page: https://github.com/truocphan/json-duplicate-keys
|
6
6
|
Author: TP Cyber Security
|
@@ -56,12 +56,13 @@ print(jdks.normalize_key("version{{{_2_}}}"))
|
|
56
56
|
```
|
57
57
|
---
|
58
58
|
|
59
|
-
### loads(`Jstr`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `_isDebug_`=False)
|
59
|
+
### loads(`Jstr`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `skipDuplicated`=False, `_isDebug_`=False)
|
60
60
|
_Deserialize a JSON format string to a class `JSON_DUPLICATE_KEYS`_
|
61
61
|
- `Jstr`: a JSON format string
|
62
62
|
- `dupSign_start`:
|
63
63
|
- `dupSign_end`:
|
64
64
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
65
|
+
- `skipDuplicated`: Skip loading duplicate keys to improve execution performance
|
65
66
|
- `_isDebug_`: Show/ Hide debug error messages
|
66
67
|
```python
|
67
68
|
import json_duplicate_keys as jdks
|
@@ -75,12 +76,13 @@ print(JDKSObject)
|
|
75
76
|
```
|
76
77
|
---
|
77
78
|
|
78
|
-
### load(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `_isDebug_`=False)
|
79
|
+
### load(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `skipDuplicated`=False, `_isDebug_`=False)
|
79
80
|
_Deserialize a JSON format string from a file to a class `JSON_DUPLICATE_KEYS`_
|
80
81
|
- `Jfilepath`: The path to the file containing the JSON format string
|
81
82
|
- `dupSign_start`:
|
82
83
|
- `dupSign_end`:
|
83
84
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
85
|
+
- `skipDuplicated`: Skip loading duplicate keys to improve execution performance
|
84
86
|
- `_isDebug_`: Show/ Hide debug error messages
|
85
87
|
```python
|
86
88
|
# /path/to/file.json: {"author": "truocphan", "version": "22.3.3", "version": "latest", "release": [{"version": "latest"}], "snapshot": {"author": "truocphan", "version": "22.3.3", "release": [{"version": "latest"}]}}
|
@@ -429,6 +431,9 @@ print(JDKSObject.getObject())
|
|
429
431
|
---
|
430
432
|
|
431
433
|
## CHANGELOG
|
434
|
+
#### [json-duplicate-keys v2025.6.6](https://github.com/truocphan/json-duplicate-keys/tree/2025.6.6)
|
435
|
+
- [**Updated**] Added `skipDuplicated` parameter to `load` and `loads` functions to improve performance when parsing large JSON strings by skipping duplicate keys.
|
436
|
+
|
432
437
|
#### [json-duplicate-keys v2024.12.12](https://github.com/truocphan/json-duplicate-keys/tree/2024.12.12)
|
433
438
|
- **New**: _insert_ function
|
434
439
|
|
@@ -0,0 +1,6 @@
|
|
1
|
+
json_duplicate_keys/__init__.py,sha256=vxG-My8fNJiG90q6flLf0_vmOJVyWjjm96ESP1grFn8,29024
|
2
|
+
json_duplicate_keys-2025.6.6.dist-info/LICENSE,sha256=_hudSGMciUc27wGR8EMKfeb3atJRlf6rbhJtLnel-nc,1093
|
3
|
+
json_duplicate_keys-2025.6.6.dist-info/METADATA,sha256=BELit1CyMqG530hTLEkU43h1sxcx7r0JE7o0Vv34rzs,21194
|
4
|
+
json_duplicate_keys-2025.6.6.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
5
|
+
json_duplicate_keys-2025.6.6.dist-info/top_level.txt,sha256=vdsGrPLVS_l-BFL1i4hCJBY5_-gq4Cwp-11yegA750Y,20
|
6
|
+
json_duplicate_keys-2025.6.6.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
json_duplicate_keys/__init__.py,sha256=UDxU0fqzAmlqzxZq5Kt_AB07zxkJSGOxir2ZCdXZygc,28844
|
2
|
-
json_duplicate_keys-2024.12.12.dist-info/LICENSE,sha256=_hudSGMciUc27wGR8EMKfeb3atJRlf6rbhJtLnel-nc,1093
|
3
|
-
json_duplicate_keys-2024.12.12.dist-info/METADATA,sha256=8pMihvTXCGW5hXVQUa9Avn-0fxFIIS_6dBg02r1UrHg,20715
|
4
|
-
json_duplicate_keys-2024.12.12.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
5
|
-
json_duplicate_keys-2024.12.12.dist-info/top_level.txt,sha256=vdsGrPLVS_l-BFL1i4hCJBY5_-gq4Cwp-11yegA750Y,20
|
6
|
-
json_duplicate_keys-2024.12.12.dist-info/RECORD,,
|
File without changes
|
{json_duplicate_keys-2024.12.12.dist-info → json_duplicate_keys-2025.6.6.dist-info}/top_level.txt
RENAMED
File without changes
|