json-duplicate-keys 2025.6.6__py3-none-any.whl → 2025.7.1__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 +68 -39
- {json_duplicate_keys-2025.6.6.dist-info → json_duplicate_keys-2025.7.1.dist-info}/METADATA +42 -56
- json_duplicate_keys-2025.7.1.dist-info/RECORD +6 -0
- json_duplicate_keys-2025.6.6.dist-info/RECORD +0 -6
- {json_duplicate_keys-2025.6.6.dist-info → json_duplicate_keys-2025.7.1.dist-info}/LICENSE +0 -0
- {json_duplicate_keys-2025.6.6.dist-info → json_duplicate_keys-2025.7.1.dist-info}/WHEEL +0 -0
- {json_duplicate_keys-2025.6.6.dist-info → json_duplicate_keys-2025.7.1.dist-info}/top_level.txt +0 -0
json_duplicate_keys/__init__.py
CHANGED
@@ -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
|
|
@@ -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
|
|
@@ -0,0 +1,6 @@
|
|
1
|
+
json_duplicate_keys/__init__.py,sha256=ClhnGD0jyYwBRsOs9zHevi6WWGtnMEOjczwkUC0BMv8,30753
|
2
|
+
json_duplicate_keys-2025.7.1.dist-info/LICENSE,sha256=_hudSGMciUc27wGR8EMKfeb3atJRlf6rbhJtLnel-nc,1093
|
3
|
+
json_duplicate_keys-2025.7.1.dist-info/METADATA,sha256=wvDz2_ia5VuzhLvNiVZnrI7YJEVfjGVwy07RGb2-dQk,22717
|
4
|
+
json_duplicate_keys-2025.7.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
5
|
+
json_duplicate_keys-2025.7.1.dist-info/top_level.txt,sha256=vdsGrPLVS_l-BFL1i4hCJBY5_-gq4Cwp-11yegA750Y,20
|
6
|
+
json_duplicate_keys-2025.7.1.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
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,,
|
File without changes
|
File without changes
|
{json_duplicate_keys-2025.6.6.dist-info → json_duplicate_keys-2025.7.1.dist-info}/top_level.txt
RENAMED
File without changes
|