json-duplicate-keys 2024.12.12__tar.gz → 2025.6.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json-duplicate-keys
3
- Version: 2024.12.12
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
 
@@ -41,12 +41,13 @@ print(jdks.normalize_key("version{{{_2_}}}"))
41
41
  ```
42
42
  ---
43
43
 
44
- ### loads(`Jstr`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `_isDebug_`=False)
44
+ ### loads(`Jstr`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `skipDuplicated`=False, `_isDebug_`=False)
45
45
  _Deserialize a JSON format string to a class `JSON_DUPLICATE_KEYS`_
46
46
  - `Jstr`: a JSON format string
47
47
  - `dupSign_start`:
48
48
  - `dupSign_end`:
49
49
  - `ordered_dict`: preserves the order in which the Keys are inserted
50
+ - `skipDuplicated`: Skip loading duplicate keys to improve execution performance
50
51
  - `_isDebug_`: Show/ Hide debug error messages
51
52
  ```python
52
53
  import json_duplicate_keys as jdks
@@ -60,12 +61,13 @@ print(JDKSObject)
60
61
  ```
61
62
  ---
62
63
 
63
- ### load(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `_isDebug_`=False)
64
+ ### load(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `skipDuplicated`=False, `_isDebug_`=False)
64
65
  _Deserialize a JSON format string from a file to a class `JSON_DUPLICATE_KEYS`_
65
66
  - `Jfilepath`: The path to the file containing the JSON format string
66
67
  - `dupSign_start`:
67
68
  - `dupSign_end`:
68
69
  - `ordered_dict`: preserves the order in which the Keys are inserted
70
+ - `skipDuplicated`: Skip loading duplicate keys to improve execution performance
69
71
  - `_isDebug_`: Show/ Hide debug error messages
70
72
  ```python
71
73
  # /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"}]}}
@@ -414,6 +416,9 @@ print(JDKSObject.getObject())
414
416
  ---
415
417
 
416
418
  ## CHANGELOG
419
+ #### [json-duplicate-keys v2025.6.6](https://github.com/truocphan/json-duplicate-keys/tree/2025.6.6)
420
+ - [**Updated**] Added `skipDuplicated` parameter to `load` and `loads` functions to improve performance when parsing large JSON strings by skipping duplicate keys.
421
+
417
422
  #### [json-duplicate-keys v2024.12.12](https://github.com/truocphan/json-duplicate-keys/tree/2024.12.12)
418
423
  - **New**: _insert_ function
419
424
 
@@ -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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json-duplicate-keys
3
- Version: 2024.12.12
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
 
@@ -1,8 +1,9 @@
1
+ from json_duplicate_keys import json_duplicate_keys_VERSION
1
2
  import setuptools
2
3
 
3
4
  setuptools.setup(
4
5
  name="json-duplicate-keys",
5
- version="2024.12.12",
6
+ version=json_duplicate_keys_VERSION,
6
7
  author="TP Cyber Security",
7
8
  license="MIT",
8
9
  author_email="tpcybersec2023@gmail.com",
@@ -17,5 +18,5 @@ setuptools.setup(
17
18
  "Programming Language :: Python :: Implementation :: Jython"
18
19
  ],
19
20
  keywords=["TPCyberSec", "json", "duplicate keys", "json duplicate keys", "flatten", "unflatten"],
20
- packages=["json_duplicate_keys"],
21
+ packages=setuptools.find_packages(),
21
22
  )