json-duplicate-keys 2024.3.24__py3-none-any.whl → 2024.4.20__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 +31 -3
- {json_duplicate_keys-2024.3.24.dist-info → json_duplicate_keys-2024.4.20.dist-info}/METADATA +26 -1
- json_duplicate_keys-2024.4.20.dist-info/RECORD +6 -0
- json_duplicate_keys-2024.3.24.dist-info/RECORD +0 -6
- {json_duplicate_keys-2024.3.24.dist-info → json_duplicate_keys-2024.4.20.dist-info}/LICENSE +0 -0
- {json_duplicate_keys-2024.3.24.dist-info → json_duplicate_keys-2024.4.20.dist-info}/WHEEL +0 -0
- {json_duplicate_keys-2024.3.24.dist-info → json_duplicate_keys-2024.4.20.dist-info}/top_level.txt +0 -0
json_duplicate_keys/__init__.py
CHANGED
@@ -454,9 +454,37 @@ class JSON_DUPLICATE_KEYS:
|
|
454
454
|
JDKSObject.flatten(separator=separator, parse_index=parse_index, ordered_dict=ordered_dict)
|
455
455
|
newJDKSObject = loads("{}", ordered_dict=ordered_dict)
|
456
456
|
|
457
|
-
for k in JDKSObject.getObject():
|
458
|
-
if
|
459
|
-
|
457
|
+
for k, v in JDKSObject.getObject().items():
|
458
|
+
if type(k) == str and type(name) == str:
|
459
|
+
if re.search(name, k):
|
460
|
+
newJDKSObject.set(k, v, separator="§§"+separator+"§§", parse_index="§§"+parse_index+"§§", ordered_dict=ordered_dict)
|
461
|
+
else:
|
462
|
+
if name == k:
|
463
|
+
newJDKSObject.set(k, v, separator="§§"+separator+"§§", parse_index="§§"+parse_index+"§§", ordered_dict=ordered_dict)
|
464
|
+
|
465
|
+
return newJDKSObject
|
466
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
467
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
468
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
469
|
+
|
470
|
+
|
471
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
472
|
+
# # # # # # # # # # # # filter_values # # # # # # # # # # # # #
|
473
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
474
|
+
def filter_values(self, value, separator="||", parse_index="$", ordered_dict=False):
|
475
|
+
import re, copy
|
476
|
+
|
477
|
+
JDKSObject = copy.deepcopy(self)
|
478
|
+
JDKSObject.flatten(separator=separator, parse_index=parse_index, ordered_dict=ordered_dict)
|
479
|
+
newJDKSObject = loads("{}", ordered_dict=ordered_dict)
|
480
|
+
|
481
|
+
for k, v in JDKSObject.getObject().items():
|
482
|
+
if type(v) == str and type(value) == str:
|
483
|
+
if re.search(value, v):
|
484
|
+
newJDKSObject.set(k, v, separator="§§"+separator+"§§", parse_index="§§"+parse_index+"§§", ordered_dict=ordered_dict)
|
485
|
+
else:
|
486
|
+
if value == v:
|
487
|
+
newJDKSObject.set(k, v, separator="§§"+separator+"§§", parse_index="§§"+parse_index+"§§", ordered_dict=ordered_dict)
|
460
488
|
|
461
489
|
return newJDKSObject
|
462
490
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
{json_duplicate_keys-2024.3.24.dist-info → json_duplicate_keys-2024.4.20.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.4.20
|
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
|
@@ -272,6 +272,27 @@ print(JDKSObject.dumps())
|
|
272
272
|
```
|
273
273
|
---
|
274
274
|
|
275
|
+
### JSON_DUPLICATE_KEYS.filter_values(`value`, `separator`="||", `parse_index`="$", `ordered_dict`=False)
|
276
|
+
|
277
|
+
- `value`:
|
278
|
+
- `separator`:
|
279
|
+
- `parse_index`:
|
280
|
+
- `ordered_dict`:
|
281
|
+
```python
|
282
|
+
import json_duplicate_keys as jdks
|
283
|
+
|
284
|
+
Jstr = '{"author": "truocphan", "version": "22.3.3", "version": "latest", "release": [{"version": "latest"}], "snapshot": {"author": "truocphan", "version": "22.3.3", "release": [{"version": "latest"}]}}'
|
285
|
+
|
286
|
+
JDKSObject = jdks.loads(Jstr)
|
287
|
+
|
288
|
+
print(JDKSObject.filter_values("latest").dumps())
|
289
|
+
# OUTPUT: {"version": "latest", "release||$0$||version": "latest", "snapshot||release||$0$||version": "latest"}
|
290
|
+
|
291
|
+
print(JDKSObject.dumps())
|
292
|
+
# OUTPUT: {"author": "truocphan", "version": "22.3.3", "version": "latest", "release": [{"version": "latest"}], "snapshot": {"author": "truocphan", "version": "22.3.3", "release": [{"version": "latest"}]}}
|
293
|
+
```
|
294
|
+
---
|
295
|
+
|
275
296
|
### 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)
|
276
297
|
_Serialize a JSON object to a JSON format string_
|
277
298
|
- `dupSign_start`:
|
@@ -374,6 +395,10 @@ print(JDKSObject.getObject())
|
|
374
395
|
---
|
375
396
|
|
376
397
|
## CHANGELOG
|
398
|
+
#### [json-duplicate-keys v2024.4.20](https://github.com/truocphan/json-duplicate-keys/tree/2024.4.20)
|
399
|
+
- **New**: _filter_values_
|
400
|
+
- **Updated**: _filter_keys_
|
401
|
+
|
377
402
|
#### [json-duplicate-keys v2024.3.24](https://github.com/truocphan/json-duplicate-keys/tree/2024.3.24)
|
378
403
|
- **Updated**: _normalize_key_, _loads_, _get_, _set_, _update_, _delete_
|
379
404
|
---
|
@@ -0,0 +1,6 @@
|
|
1
|
+
json_duplicate_keys/__init__.py,sha256=ik6YYkU74fqzIGOMUimNt0V8XPcTHvo5C8ZSO_LTADg,29780
|
2
|
+
json_duplicate_keys-2024.4.20.dist-info/LICENSE,sha256=_hudSGMciUc27wGR8EMKfeb3atJRlf6rbhJtLnel-nc,1093
|
3
|
+
json_duplicate_keys-2024.4.20.dist-info/METADATA,sha256=XFcW7R5G3qN_q0_aJ7xcVs7dvSeunxK_lhiWHt1dbF4,18203
|
4
|
+
json_duplicate_keys-2024.4.20.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
|
5
|
+
json_duplicate_keys-2024.4.20.dist-info/top_level.txt,sha256=vdsGrPLVS_l-BFL1i4hCJBY5_-gq4Cwp-11yegA750Y,20
|
6
|
+
json_duplicate_keys-2024.4.20.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
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,,
|
File without changes
|
File without changes
|
{json_duplicate_keys-2024.3.24.dist-info → json_duplicate_keys-2024.4.20.dist-info}/top_level.txt
RENAMED
File without changes
|