json-duplicate-keys 2024.2.21__py3-none-any.whl → 2024.3.24__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 +24 -24
- {json_duplicate_keys-2024.2.21.dist-info → json_duplicate_keys-2024.3.24.dist-info}/METADATA +13 -8
- json_duplicate_keys-2024.3.24.dist-info/RECORD +6 -0
- {json_duplicate_keys-2024.2.21.dist-info → json_duplicate_keys-2024.3.24.dist-info}/WHEEL +1 -1
- json_duplicate_keys-2024.2.21.dist-info/RECORD +0 -6
- {json_duplicate_keys-2024.2.21.dist-info → json_duplicate_keys-2024.3.24.dist-info}/LICENSE +0 -0
- {json_duplicate_keys-2024.2.21.dist-info → json_duplicate_keys-2024.3.24.dist-info}/top_level.txt +0 -0
json_duplicate_keys/__init__.py
CHANGED
@@ -8,14 +8,12 @@ def normalize_key(name, dupSign_start="{{{", dupSign_end="}}}", _isDebug_=False)
|
|
8
8
|
if type(_isDebug_) != bool: _isDebug_ = False
|
9
9
|
try:
|
10
10
|
if type(name) not in [str, unicode]:
|
11
|
-
|
12
|
-
exit()
|
11
|
+
exit("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
13
12
|
if type(dupSign_start) not in [str, unicode]: dupSign_start = "{{{"
|
14
13
|
if type(dupSign_end) not in [str, unicode]: dupSign_end = "}}}"
|
15
14
|
except Exception as e:
|
16
15
|
if type(name) not in [str]:
|
17
|
-
|
18
|
-
exit()
|
16
|
+
exit("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
19
17
|
if type(dupSign_start) not in [str]: dupSign_start = "{{{"
|
20
18
|
if type(dupSign_end) not in [str]: dupSign_end = "}}}"
|
21
19
|
|
@@ -37,14 +35,12 @@ def loads(Jstr, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, _isD
|
|
37
35
|
if type(ordered_dict) != bool: ordered_dict = False
|
38
36
|
try:
|
39
37
|
if type(Jstr) not in [str, unicode]:
|
40
|
-
|
41
|
-
exit()
|
38
|
+
exit("\x1b[31m[-] DataTypeError: the JSON object must be str or unicode, not {}\x1b[0m".format(type(Jstr)))
|
42
39
|
if type(dupSign_start) not in [str, unicode]: dupSign_start = "{{{"
|
43
40
|
if type(dupSign_end) not in [str, unicode]: dupSign_end = "}}}"
|
44
41
|
except Exception as e:
|
45
42
|
if type(Jstr) not in [str]:
|
46
|
-
|
47
|
-
exit()
|
43
|
+
exit("\x1b[31m[-] DataTypeError: the JSON object must be str or unicode, not {}\x1b[0m".format(type(Jstr)))
|
48
44
|
if type(dupSign_start) not in [str]: dupSign_start = "{{{"
|
49
45
|
if type(dupSign_end) not in [str]: dupSign_end = "}}}"
|
50
46
|
|
@@ -195,14 +191,12 @@ class JSON_DUPLICATE_KEYS:
|
|
195
191
|
if type(_isDebug_) != bool: _isDebug_ = False
|
196
192
|
try:
|
197
193
|
if type(name) not in [str, unicode]:
|
198
|
-
|
199
|
-
exit()
|
194
|
+
exit("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
200
195
|
if type(separator) not in [str, unicode]: separator = "||"
|
201
196
|
if type(parse_index) not in [str, unicode]: parse_index = "$"
|
202
197
|
except Exception as e:
|
203
198
|
if type(name) not in [str]:
|
204
|
-
|
205
|
-
exit()
|
199
|
+
exit("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
206
200
|
if type(separator) not in [str]: separator = "||"
|
207
201
|
if type(parse_index) not in [str]: parse_index = "$"
|
208
202
|
|
@@ -246,16 +240,14 @@ class JSON_DUPLICATE_KEYS:
|
|
246
240
|
if type(ordered_dict) != bool: ordered_dict = False
|
247
241
|
try:
|
248
242
|
if type(name) not in [str, unicode]:
|
249
|
-
|
250
|
-
exit()
|
243
|
+
exit("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
251
244
|
if type(separator) not in [str, unicode]: separator = "||"
|
252
245
|
if type(parse_index) not in [str, unicode]: parse_index = "$"
|
253
246
|
if type(dupSign_start) not in [str, unicode]: dupSign_start = "{{{"
|
254
247
|
if type(dupSign_end) not in [str, unicode]: dupSign_end = "}}}"
|
255
248
|
except Exception as e:
|
256
249
|
if type(name) not in [str]:
|
257
|
-
|
258
|
-
exit()
|
250
|
+
exit("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
259
251
|
if type(separator) not in [str]: separator = "||"
|
260
252
|
if type(parse_index) not in [str]: parse_index = "$"
|
261
253
|
if type(dupSign_start) not in [str]: dupSign_start = "{{{"
|
@@ -308,6 +300,7 @@ class JSON_DUPLICATE_KEYS:
|
|
308
300
|
exec_expression += "["+repr(k)+"]"
|
309
301
|
|
310
302
|
exec(exec_expression+"="+repr(value))
|
303
|
+
return True
|
311
304
|
# Add new key
|
312
305
|
elif self.get(separator.join(name_split_first), separator=separator, parse_index=parse_index) != "JSON_DUPLICATE_KEYS_ERROR":
|
313
306
|
if type(self.get(separator.join(name_split_first), separator=separator, parse_index=parse_index)) == list:
|
@@ -331,6 +324,7 @@ class JSON_DUPLICATE_KEYS:
|
|
331
324
|
exec_expression += "["+repr(k)+"]"
|
332
325
|
|
333
326
|
exec(exec_expression+".append({"+repr(name_split_lastKey)+":"+repr(value)+"})")
|
327
|
+
return True
|
334
328
|
elif type(self.get(separator.join(name_split_first), separator=separator, parse_index=parse_index)) == dict:
|
335
329
|
exec_expression = "self.getObject()"
|
336
330
|
|
@@ -341,6 +335,7 @@ class JSON_DUPLICATE_KEYS:
|
|
341
335
|
exec_expression += "["+repr(k)+"]"
|
342
336
|
|
343
337
|
exec(exec_expression+"["+repr(name_split_lastKey)+"]="+repr(value))
|
338
|
+
return True
|
344
339
|
else:
|
345
340
|
if _isDebug_: print("\x1b[31m[-] KeyNameNotExistError: {}\x1b[0m".format(separator.join(name_split_first)))
|
346
341
|
# Add new key
|
@@ -352,6 +347,7 @@ class JSON_DUPLICATE_KEYS:
|
|
352
347
|
self.__Jobj.append({name_split_lastKey: value})
|
353
348
|
else:
|
354
349
|
self.__Jobj[name_split_lastKey] = value
|
350
|
+
return True
|
355
351
|
else:
|
356
352
|
if _isDebug_: print("\x1b[31m[-] KeyNameInvalidError: {}\x1b[0m".format(separator.join(name_split_first)))
|
357
353
|
else:
|
@@ -360,6 +356,8 @@ class JSON_DUPLICATE_KEYS:
|
|
360
356
|
if _isDebug_: print("\x1b[31m[-] ExceptionError: {}\x1b[0m".format(e))
|
361
357
|
else:
|
362
358
|
if _isDebug_: print("\x1b[31m[-] DataTypeError: the JSON object must be list, dict or OrderedDict, not {}\x1b[0m".format(type(self.getObject())))
|
359
|
+
|
360
|
+
return False
|
363
361
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
364
362
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
365
363
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
@@ -375,14 +373,12 @@ class JSON_DUPLICATE_KEYS:
|
|
375
373
|
if type(_isDebug_) != bool: _isDebug_ = False
|
376
374
|
try:
|
377
375
|
if type(name) not in [str, unicode]:
|
378
|
-
|
379
|
-
exit()
|
376
|
+
exit("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
380
377
|
if type(separator) not in [str, unicode]: separator = "||"
|
381
378
|
if type(parse_index) not in [str, unicode]: parse_index = "$"
|
382
379
|
except Exception as e:
|
383
380
|
if type(name) not in [str]:
|
384
|
-
|
385
|
-
exit()
|
381
|
+
exit("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
386
382
|
if type(separator) not in [str]: separator = "||"
|
387
383
|
if type(parse_index) not in [str]: parse_index = "$"
|
388
384
|
|
@@ -397,8 +393,11 @@ class JSON_DUPLICATE_KEYS:
|
|
397
393
|
exec_expression += "["+repr(k)+"]"
|
398
394
|
|
399
395
|
exec(exec_expression+"="+repr(value))
|
396
|
+
return True
|
400
397
|
except Exception as e:
|
401
398
|
if _isDebug_: print("\x1b[31m[-] ExceptionError: {}\x1b[0m".format(e))
|
399
|
+
|
400
|
+
return False
|
402
401
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
403
402
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
404
403
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
@@ -415,14 +414,12 @@ class JSON_DUPLICATE_KEYS:
|
|
415
414
|
|
416
415
|
try:
|
417
416
|
if type(name) not in [str, unicode]:
|
418
|
-
|
419
|
-
exit()
|
417
|
+
exit("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
420
418
|
if type(separator) not in [str, unicode]: separator = "||"
|
421
419
|
if type(parse_index) not in [str, unicode]: parse_index = "$"
|
422
420
|
except Exception as e:
|
423
421
|
if type(name) not in [str]:
|
424
|
-
|
425
|
-
exit()
|
422
|
+
exit("\x1b[31m[-] DataTypeError: the KEY name must be str or unicode, not {}\x1b[0m".format(type(name)))
|
426
423
|
if type(separator) not in [str]: separator = "||"
|
427
424
|
if type(parse_index) not in [str]: parse_index = "$"
|
428
425
|
|
@@ -437,8 +434,11 @@ class JSON_DUPLICATE_KEYS:
|
|
437
434
|
exec_expression += "["+repr(k)+"]"
|
438
435
|
|
439
436
|
exec(exec_expression)
|
437
|
+
return True
|
440
438
|
except Exception as e:
|
441
439
|
if _isDebug_: print("\x1b[31m[-] ExceptionError: {}\x1b[0m".format(e))
|
440
|
+
|
441
|
+
return False
|
442
442
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
443
443
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
444
444
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
{json_duplicate_keys-2024.2.21.dist-info → json_duplicate_keys-2024.3.24.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json-duplicate-keys
|
3
|
-
Version: 2024.
|
3
|
+
Version: 2024.3.24
|
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
|
@@ -13,16 +13,16 @@ Classifier: Programming Language :: Python :: Implementation :: Jython
|
|
13
13
|
Description-Content-Type: text/markdown
|
14
14
|
License-File: LICENSE
|
15
15
|
|
16
|
-
# JSON Duplicate Keys
|
16
|
+
# JSON Duplicate Keys - PyPI
|
17
17
|
Flatten/ Unflatten and Load(s)/ Dump(s) JSON File/ Object with Duplicate Keys
|
18
18
|
|
19
19
|
<p align="center">
|
20
|
-
<a href="https://github.com/truocphan/
|
21
|
-
<a href="#"><img src="https://img.shields.io/github/downloads/truocphan/
|
22
|
-
<a href="#"><img src="https://img.shields.io/github/stars/truocphan/
|
23
|
-
<a href="#"><img src="https://img.shields.io/github/forks/truocphan/
|
24
|
-
<a href="https://github.com/truocphan/
|
25
|
-
<a href="https://github.com/truocphan/
|
20
|
+
<a href="https://github.com/truocphan/json-duplicate-keys/releases/"><img src="https://img.shields.io/github/release/truocphan/json-duplicate-keys" height=30></a>
|
21
|
+
<a href="#"><img src="https://img.shields.io/github/downloads/truocphan/json-duplicate-keys/total" height=30></a>
|
22
|
+
<a href="#"><img src="https://img.shields.io/github/stars/truocphan/json-duplicate-keys" height=30></a>
|
23
|
+
<a href="#"><img src="https://img.shields.io/github/forks/truocphan/json-duplicate-keys" height=30></a>
|
24
|
+
<a href="https://github.com/truocphan/json-duplicate-keys/issues?q=is%3Aopen+is%3Aissue"><img src="https://img.shields.io/github/issues/truocphan/json-duplicate-keys" height=30></a>
|
25
|
+
<a href="https://github.com/truocphan/json-duplicate-keys/issues?q=is%3Aissue+is%3Aclosed"><img src="https://img.shields.io/github/issues-closed/truocphan/json-duplicate-keys" height=30></a>
|
26
26
|
<a href="https://pypi.org/project/json-duplicate-keys/" target="_blank"><img src="https://img.shields.io/badge/pypi-3775A9?style=for-the-badge&logo=pypi&logoColor=white" height=30></a>
|
27
27
|
<a href="https://www.facebook.com/61550595106970" target="_blank"><img src="https://img.shields.io/badge/Facebook-1877F2?style=for-the-badge&logo=facebook&logoColor=white" height=30></a>
|
28
28
|
<a href="https://twitter.com/TPCyberSec" target="_blank"><img src="https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" height=30></a>
|
@@ -372,3 +372,8 @@ print(JDKSObject.getObject())
|
|
372
372
|
# OUTPUT: {'author': 'truocphan', 'version': '22.3.3', 'version{{{_2_}}}': 'latest', 'release': [{'version': 'latest'}], 'snapshot': {'author': 'truocphan', 'version': '22.3.3', 'release': [{'version': 'latest'}]}}
|
373
373
|
```
|
374
374
|
---
|
375
|
+
|
376
|
+
## CHANGELOG
|
377
|
+
#### [json-duplicate-keys v2024.3.24](https://github.com/truocphan/json-duplicate-keys/tree/2024.3.24)
|
378
|
+
- **Updated**: _normalize_key_, _loads_, _get_, _set_, _update_, _delete_
|
379
|
+
---
|
@@ -0,0 +1,6 @@
|
|
1
|
+
json_duplicate_keys/__init__.py,sha256=And1gFj_CU5_cq_6AScwgeVJL-jh-0wINjqgzfujBac,28512
|
2
|
+
json_duplicate_keys-2024.3.24.dist-info/LICENSE,sha256=_hudSGMciUc27wGR8EMKfeb3atJRlf6rbhJtLnel-nc,1093
|
3
|
+
json_duplicate_keys-2024.3.24.dist-info/METADATA,sha256=gRD_kI3qYimgcTq8DfA0RxWktdLZBGmtsSnFXdDmssw,17163
|
4
|
+
json_duplicate_keys-2024.3.24.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
|
5
|
+
json_duplicate_keys-2024.3.24.dist-info/top_level.txt,sha256=vdsGrPLVS_l-BFL1i4hCJBY5_-gq4Cwp-11yegA750Y,20
|
6
|
+
json_duplicate_keys-2024.3.24.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
json_duplicate_keys/__init__.py,sha256=S3Pnw-ckvgau80EFED0X3p1y40eZBZ1Uo1dkl6MaEW0,28666
|
2
|
-
json_duplicate_keys-2024.2.21.dist-info/LICENSE,sha256=_hudSGMciUc27wGR8EMKfeb3atJRlf6rbhJtLnel-nc,1093
|
3
|
-
json_duplicate_keys-2024.2.21.dist-info/METADATA,sha256=5x3y0xFTSmMK7eW8BuJdcM3ZzxjQggN2O1bYn3HMR4I,16956
|
4
|
-
json_duplicate_keys-2024.2.21.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
5
|
-
json_duplicate_keys-2024.2.21.dist-info/top_level.txt,sha256=vdsGrPLVS_l-BFL1i4hCJBY5_-gq4Cwp-11yegA750Y,20
|
6
|
-
json_duplicate_keys-2024.2.21.dist-info/RECORD,,
|
File without changes
|
{json_duplicate_keys-2024.2.21.dist-info → json_duplicate_keys-2024.3.24.dist-info}/top_level.txt
RENAMED
File without changes
|