json-duplicate-keys 2025.6.6__tar.gz → 2025.7.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.
- {json_duplicate_keys-2025.6.6/json_duplicate_keys.egg-info → json_duplicate_keys-2025.7.1}/PKG-INFO +42 -56
- {json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1}/README.md +41 -55
- {json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1}/json_duplicate_keys/__init__.py +68 -39
- {json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1/json_duplicate_keys.egg-info}/PKG-INFO +42 -56
- {json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1}/LICENSE +0 -0
- {json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1}/MANIFEST.in +0 -0
- {json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1}/json_duplicate_keys.egg-info/SOURCES.txt +0 -0
- {json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1}/json_duplicate_keys.egg-info/dependency_links.txt +0 -0
- {json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1}/json_duplicate_keys.egg-info/top_level.txt +0 -0
- {json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1}/requirements.txt +0 -0
- {json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1}/setup.cfg +0 -0
- {json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1}/setup.py +0 -0
{json_duplicate_keys-2025.6.6/json_duplicate_keys.egg-info → json_duplicate_keys-2025.7.1}/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json-duplicate-keys
|
3
|
-
Version: 2025.
|
3
|
+
Version: 2025.7.1
|
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
|
@@ -45,8 +45,8 @@ python setup.py install
|
|
45
45
|
### normalize_key(`name`, `dupSign_start`="{{{", `dupSign_end`="}}}", `_isDebug_`=False)
|
46
46
|
_Normalize Key name_
|
47
47
|
- `name`: key name
|
48
|
-
- `dupSign_start`:
|
49
|
-
- `dupSign_end`:
|
48
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
49
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
50
50
|
- `_isDebug_`: Show/ Hide debug error messages
|
51
51
|
```python
|
52
52
|
import json_duplicate_keys as jdks
|
@@ -59,8 +59,8 @@ print(jdks.normalize_key("version{{{_2_}}}"))
|
|
59
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
|
-
- `dupSign_start`:
|
63
|
-
- `dupSign_end`:
|
62
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
63
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
64
64
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
65
65
|
- `skipDuplicated`: Skip loading duplicate keys to improve execution performance
|
66
66
|
- `_isDebug_`: Show/ Hide debug error messages
|
@@ -79,8 +79,8 @@ print(JDKSObject)
|
|
79
79
|
### load(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `skipDuplicated`=False, `_isDebug_`=False)
|
80
80
|
_Deserialize a JSON format string from a file to a class `JSON_DUPLICATE_KEYS`_
|
81
81
|
- `Jfilepath`: The path to the file containing the JSON format string
|
82
|
-
- `dupSign_start`:
|
83
|
-
- `dupSign_end`:
|
82
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
83
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
84
84
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
85
85
|
- `skipDuplicated`: Skip loading duplicate keys to improve execution performance
|
86
86
|
- `_isDebug_`: Show/ Hide debug error messages
|
@@ -116,8 +116,8 @@ print(JDKSObject.getObject())
|
|
116
116
|
_Get value in the JSON object by `name`_
|
117
117
|
- `name`: the key name of the JSON object. Supported flatten key name format
|
118
118
|
- `case_insensitive`: the key name case (in)sensitive
|
119
|
-
- `separator`:
|
120
|
-
- `parse_index`:
|
119
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
120
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
121
121
|
- `_isDebug_`: Show/ Hide debug error messages
|
122
122
|
```python
|
123
123
|
import json_duplicate_keys as jdks
|
@@ -142,10 +142,10 @@ _Set a new `name` and `value` for the JSON object_
|
|
142
142
|
- `name`: new key name for the JSON object. Supported flat key name format
|
143
143
|
- `value`: value for key `name`
|
144
144
|
- `case_insensitive`: the key name case (in)sensitive
|
145
|
-
- `separator`:
|
146
|
-
- `parse_index`:
|
147
|
-
- `dupSign_start`:
|
148
|
-
- `dupSign_end`:
|
145
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
146
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
147
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
148
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
149
149
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
150
150
|
- `_isDebug_`: Show/Hide debug error messages
|
151
151
|
```python
|
@@ -180,25 +180,6 @@ print(JDKSObject.getObject())
|
|
180
180
|
JDKSObject.set("snapshot||author", "truocphan")
|
181
181
|
print(JDKSObject.getObject())
|
182
182
|
# OUTPUT: {'author': 'truocphan', 'version': '22.3.3', 'version{{{_2_}}}': 'latest', 'release': [{'version': 'latest'}], 'snapshot': {'author': 'truocphan'}}
|
183
|
-
|
184
|
-
|
185
|
-
Jstr = '[]'
|
186
|
-
JDKSObject = jdks.loads(Jstr)
|
187
|
-
|
188
|
-
print(JDKSObject.getObject())
|
189
|
-
# OUTPUT: []
|
190
|
-
|
191
|
-
JDKSObject.set("author", "truocphan")
|
192
|
-
print(JDKSObject.getObject())
|
193
|
-
# OUTPUT: [{'author': 'truocphan'}]
|
194
|
-
|
195
|
-
JDKSObject.set("release", [])
|
196
|
-
print(JDKSObject.getObject())
|
197
|
-
# OUTPUT: [{'author': 'truocphan'}, {'release': []}]
|
198
|
-
|
199
|
-
JDKSObject.set("$1$||release||", {"version": "latest"})
|
200
|
-
print(JDKSObject.getObject())
|
201
|
-
# OUTPUT: [{'author': 'truocphan'}, {'release': [{'version': 'latest'}]}]
|
202
183
|
```
|
203
184
|
---
|
204
185
|
|
@@ -208,10 +189,10 @@ _Insert `value` at `position` in value list of `name`_
|
|
208
189
|
- `value`: new value for key `name`
|
209
190
|
- `position`: position of the `value` to insert (default insert at the last position of the list)
|
210
191
|
- `case_insensitive`: the key name case (in)sensitive
|
211
|
-
- `separator`:
|
212
|
-
- `parse_index`:
|
213
|
-
- `dupSign_start`:
|
214
|
-
- `dupSign_end`:
|
192
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
193
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
194
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
195
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
215
196
|
- `_isDebug_`: Show/ Hide debug error messages
|
216
197
|
```python
|
217
198
|
import json_duplicate_keys as jdks
|
@@ -237,10 +218,10 @@ _Update new `value` for existing `name` or Set a new `name` in the JSON object_
|
|
237
218
|
- `value`: new value for key `name`
|
238
219
|
- `case_insensitive`: the key name case (in)sensitive
|
239
220
|
- `allow_new_key`: allows to create a new key name if the key name does not exist
|
240
|
-
- `separator`:
|
241
|
-
- `parse_index`:
|
242
|
-
- `dupSign_start`:
|
243
|
-
- `dupSign_end`:
|
221
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
222
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
223
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
224
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
244
225
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
245
226
|
- `_isDebug_`: Show/ Hide debug error messages
|
246
227
|
```python
|
@@ -265,8 +246,8 @@ print(JDKSObject.getObject())
|
|
265
246
|
_Delete a key-value pair in a JSON object by key `name`_
|
266
247
|
- `name`: the key name of the JSON object. Supported flatten key name format
|
267
248
|
- `case_insensitive`: the key name case (in)sensitive
|
268
|
-
- `separator`:
|
269
|
-
- `parse_index`:
|
249
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
250
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
270
251
|
- `_isDebug_`: Show/ Hide debug error messages
|
271
252
|
```python
|
272
253
|
import json_duplicate_keys as jdks
|
@@ -288,10 +269,10 @@ print(JDKSObject.getObject())
|
|
288
269
|
---
|
289
270
|
|
290
271
|
### JSON_DUPLICATE_KEYS.filter_keys(`name`, `separator`="||", `parse_index`="$", `ordered_dict`=False)
|
291
|
-
|
272
|
+
_Return a `JSON_DUPLICATE_KEYS` object with keys matching a pattern_
|
292
273
|
- `name`:
|
293
|
-
- `separator`:
|
294
|
-
- `parse_index`:
|
274
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
275
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
295
276
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
296
277
|
```python
|
297
278
|
import json_duplicate_keys as jdks
|
@@ -309,10 +290,10 @@ print(JDKSObject.dumps())
|
|
309
290
|
---
|
310
291
|
|
311
292
|
### JSON_DUPLICATE_KEYS.filter_values(`value`, `separator`="||", `parse_index`="$", `ordered_dict`=False)
|
312
|
-
|
293
|
+
_Return a `JSON_DUPLICATE_KEYS` object with values matching a pattern_
|
313
294
|
- `value`:
|
314
|
-
- `separator`:
|
315
|
-
- `parse_index`:
|
295
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
296
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
316
297
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
317
298
|
```python
|
318
299
|
import json_duplicate_keys as jdks
|
@@ -331,8 +312,8 @@ print(JDKSObject.dumps())
|
|
331
312
|
|
332
313
|
### JSON_DUPLICATE_KEYS.dumps(`dupSign_start`="{{{", `dupSign_end`="}}}", `_isDebug_`=False, `skipkeys`=False, `ensure_ascii`=True, `check_circular`=True, `allow_nan`=True, `cls`=None, `indent`=None, `separators`=None, `default`=None, `sort_keys`=False)
|
333
314
|
_Serialize a JSON object to a JSON format string_
|
334
|
-
- `dupSign_start`:
|
335
|
-
- `dupSign_end`:
|
315
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
316
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
336
317
|
- `_isDebug_`: Show/ Hide debug error messages
|
337
318
|
- For remaining arguments, please refer to [json.dump()](https://docs.python.org/3/library/json.html#json.dump)
|
338
319
|
```python
|
@@ -357,8 +338,8 @@ print(JDKSObject.dumps())
|
|
357
338
|
### JSON_DUPLICATE_KEYS.dump(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `_isDebug_`=False, `skipkeys`=False, `ensure_ascii`=True, `check_circular`=True, `allow_nan`=True, `cls`=None, `indent`=None, `separators`=None, `default`=None, `sort_keys`=False)
|
358
339
|
_Serialize a JSON object to a JSON format string and write to a file_
|
359
340
|
- `Jfilepath`: the path to the file to save the JSON format string
|
360
|
-
- `dupSign_start`:
|
361
|
-
- `dupSign_end`:
|
341
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
342
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
362
343
|
- `_isDebug_`: Show/ Hide debug error messages
|
363
344
|
- For remaining arguments, please refer to [json.dump()](https://docs.python.org/3/library/json.html#json.dump)
|
364
345
|
```python
|
@@ -386,8 +367,8 @@ print(JDKSObject_load.getObject())
|
|
386
367
|
|
387
368
|
### JSON_DUPLICATE_KEYS.flatten(`separator`="||", `parse_index`="$", `ordered_dict`=False, `_isDebug_`=False)
|
388
369
|
_Flatten a JSON object to a single key-value pairs_
|
389
|
-
- `separator`:
|
390
|
-
- `parse_index`:
|
370
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
371
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
391
372
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
392
373
|
- `_isDebug_`: Show/ Hide debug error messages
|
393
374
|
```python
|
@@ -409,8 +390,8 @@ print(JDKSObject.getObject())
|
|
409
390
|
|
410
391
|
### JSON_DUPLICATE_KEYS.unflatten(`separator`="||", `parse_index`="$", `ordered_dict`=False, `_isDebug_`=False)
|
411
392
|
_Unflatten a flattened JSON object back to a JSON object_
|
412
|
-
- `separator`:
|
413
|
-
- `parse_index`:
|
393
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
394
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
414
395
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
415
396
|
- `_isDebug_`: Show/ Hide debug error messages
|
416
397
|
```python
|
@@ -431,6 +412,11 @@ print(JDKSObject.getObject())
|
|
431
412
|
---
|
432
413
|
|
433
414
|
## CHANGELOG
|
415
|
+
#### [json-duplicate-keys v2025.7.1](https://github.com/truocphan/json-duplicate-keys/tree/2025.7.1)
|
416
|
+
- [**Updated**] Fixed some issues when loading JSON strings with `skipDuplicated` option
|
417
|
+
- [**Updated**] Allow loading of JSON data in byte string format
|
418
|
+
- [**Updated**] Issue with getting and setting an empty list
|
419
|
+
|
434
420
|
#### [json-duplicate-keys v2025.6.6](https://github.com/truocphan/json-duplicate-keys/tree/2025.6.6)
|
435
421
|
- [**Updated**] Added `skipDuplicated` parameter to `load` and `loads` functions to improve performance when parsing large JSON strings by skipping duplicate keys.
|
436
422
|
|
@@ -30,8 +30,8 @@ python setup.py install
|
|
30
30
|
### normalize_key(`name`, `dupSign_start`="{{{", `dupSign_end`="}}}", `_isDebug_`=False)
|
31
31
|
_Normalize Key name_
|
32
32
|
- `name`: key name
|
33
|
-
- `dupSign_start`:
|
34
|
-
- `dupSign_end`:
|
33
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
34
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
35
35
|
- `_isDebug_`: Show/ Hide debug error messages
|
36
36
|
```python
|
37
37
|
import json_duplicate_keys as jdks
|
@@ -44,8 +44,8 @@ print(jdks.normalize_key("version{{{_2_}}}"))
|
|
44
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
|
-
- `dupSign_start`:
|
48
|
-
- `dupSign_end`:
|
47
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
48
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
49
49
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
50
50
|
- `skipDuplicated`: Skip loading duplicate keys to improve execution performance
|
51
51
|
- `_isDebug_`: Show/ Hide debug error messages
|
@@ -64,8 +64,8 @@ print(JDKSObject)
|
|
64
64
|
### load(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `skipDuplicated`=False, `_isDebug_`=False)
|
65
65
|
_Deserialize a JSON format string from a file to a class `JSON_DUPLICATE_KEYS`_
|
66
66
|
- `Jfilepath`: The path to the file containing the JSON format string
|
67
|
-
- `dupSign_start`:
|
68
|
-
- `dupSign_end`:
|
67
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
68
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
69
69
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
70
70
|
- `skipDuplicated`: Skip loading duplicate keys to improve execution performance
|
71
71
|
- `_isDebug_`: Show/ Hide debug error messages
|
@@ -101,8 +101,8 @@ print(JDKSObject.getObject())
|
|
101
101
|
_Get value in the JSON object by `name`_
|
102
102
|
- `name`: the key name of the JSON object. Supported flatten key name format
|
103
103
|
- `case_insensitive`: the key name case (in)sensitive
|
104
|
-
- `separator`:
|
105
|
-
- `parse_index`:
|
104
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
105
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
106
106
|
- `_isDebug_`: Show/ Hide debug error messages
|
107
107
|
```python
|
108
108
|
import json_duplicate_keys as jdks
|
@@ -127,10 +127,10 @@ _Set a new `name` and `value` for the JSON object_
|
|
127
127
|
- `name`: new key name for the JSON object. Supported flat key name format
|
128
128
|
- `value`: value for key `name`
|
129
129
|
- `case_insensitive`: the key name case (in)sensitive
|
130
|
-
- `separator`:
|
131
|
-
- `parse_index`:
|
132
|
-
- `dupSign_start`:
|
133
|
-
- `dupSign_end`:
|
130
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
131
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
132
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
133
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
134
134
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
135
135
|
- `_isDebug_`: Show/Hide debug error messages
|
136
136
|
```python
|
@@ -165,25 +165,6 @@ print(JDKSObject.getObject())
|
|
165
165
|
JDKSObject.set("snapshot||author", "truocphan")
|
166
166
|
print(JDKSObject.getObject())
|
167
167
|
# OUTPUT: {'author': 'truocphan', 'version': '22.3.3', 'version{{{_2_}}}': 'latest', 'release': [{'version': 'latest'}], 'snapshot': {'author': 'truocphan'}}
|
168
|
-
|
169
|
-
|
170
|
-
Jstr = '[]'
|
171
|
-
JDKSObject = jdks.loads(Jstr)
|
172
|
-
|
173
|
-
print(JDKSObject.getObject())
|
174
|
-
# OUTPUT: []
|
175
|
-
|
176
|
-
JDKSObject.set("author", "truocphan")
|
177
|
-
print(JDKSObject.getObject())
|
178
|
-
# OUTPUT: [{'author': 'truocphan'}]
|
179
|
-
|
180
|
-
JDKSObject.set("release", [])
|
181
|
-
print(JDKSObject.getObject())
|
182
|
-
# OUTPUT: [{'author': 'truocphan'}, {'release': []}]
|
183
|
-
|
184
|
-
JDKSObject.set("$1$||release||", {"version": "latest"})
|
185
|
-
print(JDKSObject.getObject())
|
186
|
-
# OUTPUT: [{'author': 'truocphan'}, {'release': [{'version': 'latest'}]}]
|
187
168
|
```
|
188
169
|
---
|
189
170
|
|
@@ -193,10 +174,10 @@ _Insert `value` at `position` in value list of `name`_
|
|
193
174
|
- `value`: new value for key `name`
|
194
175
|
- `position`: position of the `value` to insert (default insert at the last position of the list)
|
195
176
|
- `case_insensitive`: the key name case (in)sensitive
|
196
|
-
- `separator`:
|
197
|
-
- `parse_index`:
|
198
|
-
- `dupSign_start`:
|
199
|
-
- `dupSign_end`:
|
177
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
178
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
179
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
180
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
200
181
|
- `_isDebug_`: Show/ Hide debug error messages
|
201
182
|
```python
|
202
183
|
import json_duplicate_keys as jdks
|
@@ -222,10 +203,10 @@ _Update new `value` for existing `name` or Set a new `name` in the JSON object_
|
|
222
203
|
- `value`: new value for key `name`
|
223
204
|
- `case_insensitive`: the key name case (in)sensitive
|
224
205
|
- `allow_new_key`: allows to create a new key name if the key name does not exist
|
225
|
-
- `separator`:
|
226
|
-
- `parse_index`:
|
227
|
-
- `dupSign_start`:
|
228
|
-
- `dupSign_end`:
|
206
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
207
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
208
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
209
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
229
210
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
230
211
|
- `_isDebug_`: Show/ Hide debug error messages
|
231
212
|
```python
|
@@ -250,8 +231,8 @@ print(JDKSObject.getObject())
|
|
250
231
|
_Delete a key-value pair in a JSON object by key `name`_
|
251
232
|
- `name`: the key name of the JSON object. Supported flatten key name format
|
252
233
|
- `case_insensitive`: the key name case (in)sensitive
|
253
|
-
- `separator`:
|
254
|
-
- `parse_index`:
|
234
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
235
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
255
236
|
- `_isDebug_`: Show/ Hide debug error messages
|
256
237
|
```python
|
257
238
|
import json_duplicate_keys as jdks
|
@@ -273,10 +254,10 @@ print(JDKSObject.getObject())
|
|
273
254
|
---
|
274
255
|
|
275
256
|
### JSON_DUPLICATE_KEYS.filter_keys(`name`, `separator`="||", `parse_index`="$", `ordered_dict`=False)
|
276
|
-
|
257
|
+
_Return a `JSON_DUPLICATE_KEYS` object with keys matching a pattern_
|
277
258
|
- `name`:
|
278
|
-
- `separator`:
|
279
|
-
- `parse_index`:
|
259
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
260
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
280
261
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
281
262
|
```python
|
282
263
|
import json_duplicate_keys as jdks
|
@@ -294,10 +275,10 @@ print(JDKSObject.dumps())
|
|
294
275
|
---
|
295
276
|
|
296
277
|
### JSON_DUPLICATE_KEYS.filter_values(`value`, `separator`="||", `parse_index`="$", `ordered_dict`=False)
|
297
|
-
|
278
|
+
_Return a `JSON_DUPLICATE_KEYS` object with values matching a pattern_
|
298
279
|
- `value`:
|
299
|
-
- `separator`:
|
300
|
-
- `parse_index`:
|
280
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
281
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
301
282
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
302
283
|
```python
|
303
284
|
import json_duplicate_keys as jdks
|
@@ -316,8 +297,8 @@ print(JDKSObject.dumps())
|
|
316
297
|
|
317
298
|
### JSON_DUPLICATE_KEYS.dumps(`dupSign_start`="{{{", `dupSign_end`="}}}", `_isDebug_`=False, `skipkeys`=False, `ensure_ascii`=True, `check_circular`=True, `allow_nan`=True, `cls`=None, `indent`=None, `separators`=None, `default`=None, `sort_keys`=False)
|
318
299
|
_Serialize a JSON object to a JSON format string_
|
319
|
-
- `dupSign_start`:
|
320
|
-
- `dupSign_end`:
|
300
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
301
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
321
302
|
- `_isDebug_`: Show/ Hide debug error messages
|
322
303
|
- For remaining arguments, please refer to [json.dump()](https://docs.python.org/3/library/json.html#json.dump)
|
323
304
|
```python
|
@@ -342,8 +323,8 @@ print(JDKSObject.dumps())
|
|
342
323
|
### JSON_DUPLICATE_KEYS.dump(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `_isDebug_`=False, `skipkeys`=False, `ensure_ascii`=True, `check_circular`=True, `allow_nan`=True, `cls`=None, `indent`=None, `separators`=None, `default`=None, `sort_keys`=False)
|
343
324
|
_Serialize a JSON object to a JSON format string and write to a file_
|
344
325
|
- `Jfilepath`: the path to the file to save the JSON format string
|
345
|
-
- `dupSign_start`:
|
346
|
-
- `dupSign_end`:
|
326
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
327
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
347
328
|
- `_isDebug_`: Show/ Hide debug error messages
|
348
329
|
- For remaining arguments, please refer to [json.dump()](https://docs.python.org/3/library/json.html#json.dump)
|
349
330
|
```python
|
@@ -371,8 +352,8 @@ print(JDKSObject_load.getObject())
|
|
371
352
|
|
372
353
|
### JSON_DUPLICATE_KEYS.flatten(`separator`="||", `parse_index`="$", `ordered_dict`=False, `_isDebug_`=False)
|
373
354
|
_Flatten a JSON object to a single key-value pairs_
|
374
|
-
- `separator`:
|
375
|
-
- `parse_index`:
|
355
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
356
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
376
357
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
377
358
|
- `_isDebug_`: Show/ Hide debug error messages
|
378
359
|
```python
|
@@ -394,8 +375,8 @@ print(JDKSObject.getObject())
|
|
394
375
|
|
395
376
|
### JSON_DUPLICATE_KEYS.unflatten(`separator`="||", `parse_index`="$", `ordered_dict`=False, `_isDebug_`=False)
|
396
377
|
_Unflatten a flattened JSON object back to a JSON object_
|
397
|
-
- `separator`:
|
398
|
-
- `parse_index`:
|
378
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
379
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
399
380
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
400
381
|
- `_isDebug_`: Show/ Hide debug error messages
|
401
382
|
```python
|
@@ -416,6 +397,11 @@ print(JDKSObject.getObject())
|
|
416
397
|
---
|
417
398
|
|
418
399
|
## CHANGELOG
|
400
|
+
#### [json-duplicate-keys v2025.7.1](https://github.com/truocphan/json-duplicate-keys/tree/2025.7.1)
|
401
|
+
- [**Updated**] Fixed some issues when loading JSON strings with `skipDuplicated` option
|
402
|
+
- [**Updated**] Allow loading of JSON data in byte string format
|
403
|
+
- [**Updated**] Issue with getting and setting an empty list
|
404
|
+
|
419
405
|
#### [json-duplicate-keys v2025.6.6](https://github.com/truocphan/json-duplicate-keys/tree/2025.6.6)
|
420
406
|
- [**Updated**] Added `skipDuplicated` parameter to `load` and `loads` functions to improve performance when parsing large JSON strings by skipping duplicate keys.
|
421
407
|
|
{json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1}/json_duplicate_keys/__init__.py
RENAMED
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
json_duplicate_keys_VERSION = "2025.
|
2
|
+
json_duplicate_keys_VERSION = "2025.7.1"
|
3
|
+
|
3
4
|
try:
|
4
5
|
unicode # Python 2
|
5
6
|
except NameError:
|
@@ -36,10 +37,12 @@ def loads(Jstr, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, skip
|
|
36
37
|
# User input data type validation
|
37
38
|
if type(_isDebug_) != bool: _isDebug_ = False
|
38
39
|
|
40
|
+
if type(skipDuplicated) != bool: skipDuplicated = False
|
41
|
+
|
39
42
|
if type(ordered_dict) != bool: ordered_dict = False
|
40
43
|
|
41
|
-
if type(Jstr) not in [str, unicode]:
|
42
|
-
if _isDebug_: print("\x1b[31m[-] DataTypeError: the JSON object must be str or
|
44
|
+
if type(Jstr) not in [str, unicode, bytes]:
|
45
|
+
if _isDebug_: print("\x1b[31m[-] DataTypeError: the JSON object must be str, unicode or bytes, not {}\x1b[0m".format(type(Jstr)))
|
43
46
|
return False
|
44
47
|
|
45
48
|
if type(dupSign_start) not in [str, unicode]: dupSign_start = "{{{"
|
@@ -95,7 +98,11 @@ def loads(Jstr, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, skip
|
|
95
98
|
if ordered_dict: Jloads = json.loads(Jstr, object_pairs_hook=OrderedDict)
|
96
99
|
|
97
100
|
if skipDuplicated:
|
98
|
-
|
101
|
+
if type(Jloads) in [list, dict, OrderedDict]:
|
102
|
+
return JSON_DUPLICATE_KEYS(Jloads)
|
103
|
+
else:
|
104
|
+
if _isDebug_: print("\x1b[31m[-] DataError: Invalid JSON format\x1b[0m")
|
105
|
+
return False
|
99
106
|
|
100
107
|
if type(Jloads) in [list, dict, OrderedDict]:
|
101
108
|
dupSign_start_escape = "".join(["\\\\u"+hex(ord(c))[2:].zfill(4) for c in dupSign_start])
|
@@ -105,23 +112,41 @@ def loads(Jstr, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, skip
|
|
105
112
|
dupSign_end_escape_regex = re.escape(dupSign_end)
|
106
113
|
|
107
114
|
|
108
|
-
|
109
|
-
|
110
|
-
|
115
|
+
if type(Jstr) == bytes:
|
116
|
+
Jstr = re.sub(r'\\\\'.encode(), '\x00\x01'.encode(), Jstr)
|
117
|
+
Jstr = re.sub(r'\\"'.encode(), '\x02\x03'.encode(), Jstr)
|
118
|
+
Jstr = re.sub(r'"([^"]*)"[\s\t\r\n]*([,\]}])'.encode(), '\x04\x05\\1\x04\x05\\2'.encode(), Jstr)
|
119
|
+
|
111
120
|
|
121
|
+
Jstr = re.sub(r'"([^"]+)"[\s\t\r\n]*:'.encode(), r'"\1{dupSign_start}_dupSign_{dupSign_end}":'.format(dupSign_start=dupSign_start_escape, dupSign_end=dupSign_end_escape).encode(), Jstr)
|
112
122
|
|
113
|
-
|
123
|
+
Jstr = re.sub(r'""[\s\t\r\n]*:'.encode(), '"{dupSign_start}_dupSign_{dupSign_end}":'.format(dupSign_start=dupSign_start_escape, dupSign_end=dupSign_end_escape).encode(), Jstr)
|
114
124
|
|
115
|
-
|
125
|
+
i = 0
|
126
|
+
while re.search(r'{dupSign_start}_dupSign_{dupSign_end}"[\s\t\r\n]*:'.format(dupSign_start=dupSign_start_escape, dupSign_end=dupSign_end_escape).encode(), Jstr):
|
127
|
+
Jstr = re.sub(r'{dupSign_start}_dupSign_{dupSign_end}"[\s\t\r\n]*:'.format(dupSign_start=dupSign_start_escape, dupSign_end=dupSign_end_escape).encode(), (dupSign_start_escape+"_"+str(i)+"_"+dupSign_end_escape+'":').encode(), Jstr, 1)
|
128
|
+
i += 1
|
116
129
|
|
117
|
-
|
118
|
-
|
119
|
-
Jstr = re.sub(
|
120
|
-
|
130
|
+
Jstr = re.sub('\x00\x01'.encode(), r'\\\\'.encode(), Jstr)
|
131
|
+
Jstr = re.sub('\x02\x03'.encode(), r'\\"'.encode(), Jstr)
|
132
|
+
Jstr = re.sub('\x04\x05'.encode(), r'"'.encode(), Jstr)
|
133
|
+
else:
|
134
|
+
Jstr = re.sub(r'\\\\', '\x00\x01', Jstr)
|
135
|
+
Jstr = re.sub(r'\\"', '\x02\x03', Jstr)
|
136
|
+
Jstr = re.sub(r'"([^"]*)"[\s\t\r\n]*([,\]}])', '\x04\x05\\1\x04\x05\\2', Jstr)
|
137
|
+
|
138
|
+
Jstr = re.sub(r'"([^"]+)"[\s\t\r\n]*:', r'"\1{dupSign_start}_dupSign_{dupSign_end}":'.format(dupSign_start=dupSign_start_escape, dupSign_end=dupSign_end_escape), Jstr)
|
139
|
+
|
140
|
+
Jstr = re.sub(r'""[\s\t\r\n]*:', '"{dupSign_start}_dupSign_{dupSign_end}":'.format(dupSign_start=dupSign_start_escape, dupSign_end=dupSign_end_escape), Jstr)
|
121
141
|
|
122
|
-
|
123
|
-
|
124
|
-
|
142
|
+
i = 0
|
143
|
+
while re.search(r'{dupSign_start}_dupSign_{dupSign_end}"[\s\t\r\n]*:'.format(dupSign_start=dupSign_start_escape, dupSign_end=dupSign_end_escape), Jstr):
|
144
|
+
Jstr = re.sub(r'{dupSign_start}_dupSign_{dupSign_end}"[\s\t\r\n]*:'.format(dupSign_start=dupSign_start_escape, dupSign_end=dupSign_end_escape), dupSign_start_escape+"_"+str(i)+"_"+dupSign_end_escape+'":', Jstr, 1)
|
145
|
+
i += 1
|
146
|
+
|
147
|
+
Jstr = re.sub('\x00\x01', r'\\\\', Jstr)
|
148
|
+
Jstr = re.sub('\x02\x03', r'\\"', Jstr)
|
149
|
+
Jstr = re.sub('\x04\x05', r'"', Jstr)
|
125
150
|
|
126
151
|
Jloads = json.loads(Jstr)
|
127
152
|
if ordered_dict:
|
@@ -153,13 +178,11 @@ def loads(Jstr, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, skip
|
|
153
178
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
154
179
|
def load(Jfilepath, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, skipDuplicated=False, _isDebug_=False):
|
155
180
|
try:
|
156
|
-
with open(Jfilepath) as Jfile:
|
157
|
-
Jstr = Jfile.read()
|
158
|
-
|
159
|
-
return loads(Jstr, dupSign_start=dupSign_start, dupSign_end=dupSign_end, ordered_dict=ordered_dict, skipDuplicated=skipDuplicated, _isDebug_=_isDebug_)
|
181
|
+
with open(Jfilepath) as Jfile: Jstr = Jfile.read()
|
160
182
|
except Exception as e:
|
161
|
-
|
162
|
-
|
183
|
+
with open(Jfilepath, "rb") as Jfile: Jstr = Jfile.read()
|
184
|
+
|
185
|
+
return loads(Jstr, dupSign_start=dupSign_start, dupSign_end=dupSign_end, ordered_dict=ordered_dict, skipDuplicated=skipDuplicated, _isDebug_=_isDebug_)
|
163
186
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
164
187
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
165
188
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
@@ -192,7 +215,7 @@ class JSON_DUPLICATE_KEYS:
|
|
192
215
|
# User input data type validation
|
193
216
|
if type(_isDebug_) != bool: _isDebug_ = False
|
194
217
|
|
195
|
-
if type(name) not in [str, unicode]:
|
218
|
+
if type(name) not in [str, unicode]:
|
196
219
|
if _isDebug_: print("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
197
220
|
return {"name":name, "value":"JSON_DUPLICATE_KEYS_ERROR"}
|
198
221
|
|
@@ -215,16 +238,18 @@ class JSON_DUPLICATE_KEYS:
|
|
215
238
|
Jname = []
|
216
239
|
Jval = self.__Jobj
|
217
240
|
name_split = name.split(separator)
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
241
|
+
|
242
|
+
if type(Jobj.getObject()) in [dict, OrderedDict]:
|
243
|
+
for k in Jobj.getObject().keys():
|
244
|
+
if len(k.split(separator)) >= len(name_split):
|
245
|
+
if case_insensitive:
|
246
|
+
if separator.join(k.split(separator)[:len(name_split)]).lower() == name.lower():
|
247
|
+
Jname = k.split(separator)[:len(name_split)]
|
248
|
+
break
|
249
|
+
else:
|
250
|
+
if separator.join(k.split(separator)[:len(name_split)]) == name:
|
251
|
+
Jname = name_split
|
252
|
+
break
|
228
253
|
|
229
254
|
if len(Jname) > 0:
|
230
255
|
for k in Jname:
|
@@ -250,7 +275,7 @@ class JSON_DUPLICATE_KEYS:
|
|
250
275
|
|
251
276
|
if type(ordered_dict) != bool: ordered_dict = False
|
252
277
|
|
253
|
-
if type(name) not in [str, unicode]:
|
278
|
+
if type(name) not in [str, unicode]:
|
254
279
|
if _isDebug_: print("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
255
280
|
return False
|
256
281
|
|
@@ -297,8 +322,12 @@ class JSON_DUPLICATE_KEYS:
|
|
297
322
|
return True
|
298
323
|
else:
|
299
324
|
if len(name.split(separator)) == 1:
|
300
|
-
self.getObject()[
|
301
|
-
|
325
|
+
if type(self.getObject()) in [dict, OrderedDict]:
|
326
|
+
self.getObject()[name] = value
|
327
|
+
return True
|
328
|
+
else:
|
329
|
+
if _isDebug_: print("\x1b[31m[-] DataTypeError: Cannot set name and value for a list object\x1b[0m")
|
330
|
+
return False
|
302
331
|
else:
|
303
332
|
if self.get(separator.join(name.split(separator)[:-1]), case_insensitive=case_insensitive, separator=separator, parse_index=parse_index)["value"] != "JSON_DUPLICATE_KEYS_ERROR":
|
304
333
|
Jget = self.get(separator.join(name.split(separator)[:-1]), case_insensitive=case_insensitive, separator=separator, parse_index=parse_index)
|
@@ -331,7 +360,7 @@ class JSON_DUPLICATE_KEYS:
|
|
331
360
|
# User input data type validation
|
332
361
|
if type(_isDebug_) != bool: _isDebug_ = False
|
333
362
|
|
334
|
-
if type(name) not in [str, unicode]:
|
363
|
+
if type(name) not in [str, unicode]:
|
335
364
|
if _isDebug_: print("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
336
365
|
return False
|
337
366
|
|
@@ -376,7 +405,7 @@ class JSON_DUPLICATE_KEYS:
|
|
376
405
|
# User input data type validation
|
377
406
|
if type(_isDebug_) != bool: _isDebug_ = False
|
378
407
|
|
379
|
-
if type(name) not in [str, unicode]:
|
408
|
+
if type(name) not in [str, unicode]:
|
380
409
|
if _isDebug_: print("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
381
410
|
return False
|
382
411
|
|
@@ -420,7 +449,7 @@ class JSON_DUPLICATE_KEYS:
|
|
420
449
|
# User input data type validation
|
421
450
|
if type(_isDebug_) != bool: _isDebug_ = False
|
422
451
|
|
423
|
-
if type(name) not in [str, unicode]:
|
452
|
+
if type(name) not in [str, unicode]:
|
424
453
|
if _isDebug_: print("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
425
454
|
return False
|
426
455
|
|
{json_duplicate_keys-2025.6.6 → json_duplicate_keys-2025.7.1/json_duplicate_keys.egg-info}/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json-duplicate-keys
|
3
|
-
Version: 2025.
|
3
|
+
Version: 2025.7.1
|
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
|
@@ -45,8 +45,8 @@ python setup.py install
|
|
45
45
|
### normalize_key(`name`, `dupSign_start`="{{{", `dupSign_end`="}}}", `_isDebug_`=False)
|
46
46
|
_Normalize Key name_
|
47
47
|
- `name`: key name
|
48
|
-
- `dupSign_start`:
|
49
|
-
- `dupSign_end`:
|
48
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
49
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
50
50
|
- `_isDebug_`: Show/ Hide debug error messages
|
51
51
|
```python
|
52
52
|
import json_duplicate_keys as jdks
|
@@ -59,8 +59,8 @@ print(jdks.normalize_key("version{{{_2_}}}"))
|
|
59
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
|
-
- `dupSign_start`:
|
63
|
-
- `dupSign_end`:
|
62
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
63
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
64
64
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
65
65
|
- `skipDuplicated`: Skip loading duplicate keys to improve execution performance
|
66
66
|
- `_isDebug_`: Show/ Hide debug error messages
|
@@ -79,8 +79,8 @@ print(JDKSObject)
|
|
79
79
|
### load(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `skipDuplicated`=False, `_isDebug_`=False)
|
80
80
|
_Deserialize a JSON format string from a file to a class `JSON_DUPLICATE_KEYS`_
|
81
81
|
- `Jfilepath`: The path to the file containing the JSON format string
|
82
|
-
- `dupSign_start`:
|
83
|
-
- `dupSign_end`:
|
82
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
83
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
84
84
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
85
85
|
- `skipDuplicated`: Skip loading duplicate keys to improve execution performance
|
86
86
|
- `_isDebug_`: Show/ Hide debug error messages
|
@@ -116,8 +116,8 @@ print(JDKSObject.getObject())
|
|
116
116
|
_Get value in the JSON object by `name`_
|
117
117
|
- `name`: the key name of the JSON object. Supported flatten key name format
|
118
118
|
- `case_insensitive`: the key name case (in)sensitive
|
119
|
-
- `separator`:
|
120
|
-
- `parse_index`:
|
119
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
120
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
121
121
|
- `_isDebug_`: Show/ Hide debug error messages
|
122
122
|
```python
|
123
123
|
import json_duplicate_keys as jdks
|
@@ -142,10 +142,10 @@ _Set a new `name` and `value` for the JSON object_
|
|
142
142
|
- `name`: new key name for the JSON object. Supported flat key name format
|
143
143
|
- `value`: value for key `name`
|
144
144
|
- `case_insensitive`: the key name case (in)sensitive
|
145
|
-
- `separator`:
|
146
|
-
- `parse_index`:
|
147
|
-
- `dupSign_start`:
|
148
|
-
- `dupSign_end`:
|
145
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
146
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
147
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
148
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
149
149
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
150
150
|
- `_isDebug_`: Show/Hide debug error messages
|
151
151
|
```python
|
@@ -180,25 +180,6 @@ print(JDKSObject.getObject())
|
|
180
180
|
JDKSObject.set("snapshot||author", "truocphan")
|
181
181
|
print(JDKSObject.getObject())
|
182
182
|
# OUTPUT: {'author': 'truocphan', 'version': '22.3.3', 'version{{{_2_}}}': 'latest', 'release': [{'version': 'latest'}], 'snapshot': {'author': 'truocphan'}}
|
183
|
-
|
184
|
-
|
185
|
-
Jstr = '[]'
|
186
|
-
JDKSObject = jdks.loads(Jstr)
|
187
|
-
|
188
|
-
print(JDKSObject.getObject())
|
189
|
-
# OUTPUT: []
|
190
|
-
|
191
|
-
JDKSObject.set("author", "truocphan")
|
192
|
-
print(JDKSObject.getObject())
|
193
|
-
# OUTPUT: [{'author': 'truocphan'}]
|
194
|
-
|
195
|
-
JDKSObject.set("release", [])
|
196
|
-
print(JDKSObject.getObject())
|
197
|
-
# OUTPUT: [{'author': 'truocphan'}, {'release': []}]
|
198
|
-
|
199
|
-
JDKSObject.set("$1$||release||", {"version": "latest"})
|
200
|
-
print(JDKSObject.getObject())
|
201
|
-
# OUTPUT: [{'author': 'truocphan'}, {'release': [{'version': 'latest'}]}]
|
202
183
|
```
|
203
184
|
---
|
204
185
|
|
@@ -208,10 +189,10 @@ _Insert `value` at `position` in value list of `name`_
|
|
208
189
|
- `value`: new value for key `name`
|
209
190
|
- `position`: position of the `value` to insert (default insert at the last position of the list)
|
210
191
|
- `case_insensitive`: the key name case (in)sensitive
|
211
|
-
- `separator`:
|
212
|
-
- `parse_index`:
|
213
|
-
- `dupSign_start`:
|
214
|
-
- `dupSign_end`:
|
192
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
193
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
194
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
195
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
215
196
|
- `_isDebug_`: Show/ Hide debug error messages
|
216
197
|
```python
|
217
198
|
import json_duplicate_keys as jdks
|
@@ -237,10 +218,10 @@ _Update new `value` for existing `name` or Set a new `name` in the JSON object_
|
|
237
218
|
- `value`: new value for key `name`
|
238
219
|
- `case_insensitive`: the key name case (in)sensitive
|
239
220
|
- `allow_new_key`: allows to create a new key name if the key name does not exist
|
240
|
-
- `separator`:
|
241
|
-
- `parse_index`:
|
242
|
-
- `dupSign_start`:
|
243
|
-
- `dupSign_end`:
|
221
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
222
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
223
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
224
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
244
225
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
245
226
|
- `_isDebug_`: Show/ Hide debug error messages
|
246
227
|
```python
|
@@ -265,8 +246,8 @@ print(JDKSObject.getObject())
|
|
265
246
|
_Delete a key-value pair in a JSON object by key `name`_
|
266
247
|
- `name`: the key name of the JSON object. Supported flatten key name format
|
267
248
|
- `case_insensitive`: the key name case (in)sensitive
|
268
|
-
- `separator`:
|
269
|
-
- `parse_index`:
|
249
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
250
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
270
251
|
- `_isDebug_`: Show/ Hide debug error messages
|
271
252
|
```python
|
272
253
|
import json_duplicate_keys as jdks
|
@@ -288,10 +269,10 @@ print(JDKSObject.getObject())
|
|
288
269
|
---
|
289
270
|
|
290
271
|
### JSON_DUPLICATE_KEYS.filter_keys(`name`, `separator`="||", `parse_index`="$", `ordered_dict`=False)
|
291
|
-
|
272
|
+
_Return a `JSON_DUPLICATE_KEYS` object with keys matching a pattern_
|
292
273
|
- `name`:
|
293
|
-
- `separator`:
|
294
|
-
- `parse_index`:
|
274
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
275
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
295
276
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
296
277
|
```python
|
297
278
|
import json_duplicate_keys as jdks
|
@@ -309,10 +290,10 @@ print(JDKSObject.dumps())
|
|
309
290
|
---
|
310
291
|
|
311
292
|
### JSON_DUPLICATE_KEYS.filter_values(`value`, `separator`="||", `parse_index`="$", `ordered_dict`=False)
|
312
|
-
|
293
|
+
_Return a `JSON_DUPLICATE_KEYS` object with values matching a pattern_
|
313
294
|
- `value`:
|
314
|
-
- `separator`:
|
315
|
-
- `parse_index`:
|
295
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
296
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
316
297
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
317
298
|
```python
|
318
299
|
import json_duplicate_keys as jdks
|
@@ -331,8 +312,8 @@ print(JDKSObject.dumps())
|
|
331
312
|
|
332
313
|
### JSON_DUPLICATE_KEYS.dumps(`dupSign_start`="{{{", `dupSign_end`="}}}", `_isDebug_`=False, `skipkeys`=False, `ensure_ascii`=True, `check_circular`=True, `allow_nan`=True, `cls`=None, `indent`=None, `separators`=None, `default`=None, `sort_keys`=False)
|
333
314
|
_Serialize a JSON object to a JSON format string_
|
334
|
-
- `dupSign_start`:
|
335
|
-
- `dupSign_end`:
|
315
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
316
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
336
317
|
- `_isDebug_`: Show/ Hide debug error messages
|
337
318
|
- For remaining arguments, please refer to [json.dump()](https://docs.python.org/3/library/json.html#json.dump)
|
338
319
|
```python
|
@@ -357,8 +338,8 @@ print(JDKSObject.dumps())
|
|
357
338
|
### JSON_DUPLICATE_KEYS.dump(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `_isDebug_`=False, `skipkeys`=False, `ensure_ascii`=True, `check_circular`=True, `allow_nan`=True, `cls`=None, `indent`=None, `separators`=None, `default`=None, `sort_keys`=False)
|
358
339
|
_Serialize a JSON object to a JSON format string and write to a file_
|
359
340
|
- `Jfilepath`: the path to the file to save the JSON format string
|
360
|
-
- `dupSign_start`:
|
361
|
-
- `dupSign_end`:
|
341
|
+
- `dupSign_start`: Start symbol for marking duplicates (default: `{{{`)
|
342
|
+
- `dupSign_end`: End symbol for marking duplicates (default: `}}}`)
|
362
343
|
- `_isDebug_`: Show/ Hide debug error messages
|
363
344
|
- For remaining arguments, please refer to [json.dump()](https://docs.python.org/3/library/json.html#json.dump)
|
364
345
|
```python
|
@@ -386,8 +367,8 @@ print(JDKSObject_load.getObject())
|
|
386
367
|
|
387
368
|
### JSON_DUPLICATE_KEYS.flatten(`separator`="||", `parse_index`="$", `ordered_dict`=False, `_isDebug_`=False)
|
388
369
|
_Flatten a JSON object to a single key-value pairs_
|
389
|
-
- `separator`:
|
390
|
-
- `parse_index`:
|
370
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
371
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
391
372
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
392
373
|
- `_isDebug_`: Show/ Hide debug error messages
|
393
374
|
```python
|
@@ -409,8 +390,8 @@ print(JDKSObject.getObject())
|
|
409
390
|
|
410
391
|
### JSON_DUPLICATE_KEYS.unflatten(`separator`="||", `parse_index`="$", `ordered_dict`=False, `_isDebug_`=False)
|
411
392
|
_Unflatten a flattened JSON object back to a JSON object_
|
412
|
-
- `separator`:
|
413
|
-
- `parse_index`:
|
393
|
+
- `separator`: Separator for flatten keys (default: `||`)
|
394
|
+
- `parse_index`: Symbol for index parsing (default: `$`)
|
414
395
|
- `ordered_dict`: preserves the order in which the Keys are inserted
|
415
396
|
- `_isDebug_`: Show/ Hide debug error messages
|
416
397
|
```python
|
@@ -431,6 +412,11 @@ print(JDKSObject.getObject())
|
|
431
412
|
---
|
432
413
|
|
433
414
|
## CHANGELOG
|
415
|
+
#### [json-duplicate-keys v2025.7.1](https://github.com/truocphan/json-duplicate-keys/tree/2025.7.1)
|
416
|
+
- [**Updated**] Fixed some issues when loading JSON strings with `skipDuplicated` option
|
417
|
+
- [**Updated**] Allow loading of JSON data in byte string format
|
418
|
+
- [**Updated**] Issue with getting and setting an empty list
|
419
|
+
|
434
420
|
#### [json-duplicate-keys v2025.6.6](https://github.com/truocphan/json-duplicate-keys/tree/2025.6.6)
|
435
421
|
- [**Updated**] Added `skipDuplicated` parameter to `load` and `loads` functions to improve performance when parsing large JSON strings by skipping duplicate keys.
|
436
422
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|