json-duplicate-keys 2024.3.24__py2-none-any.whl → 2024.4.20__py2-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.
@@ -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 re.search(name, k):
459
- newJDKSObject.set(k, JDKSObject.get(k, separator="§§"+separator+"§§", parse_index="§§"+parse_index+"§§"), separator="§§"+separator+"§§", parse_index="§§"+parse_index+"§§", ordered_dict=ordered_dict)
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
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json-duplicate-keys
3
- Version: 2024.3.24
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=OOm04jSjn4RtgRd9pPhdRHPhMf_wEvykdruAluYRIzU,17796
4
+ json_duplicate_keys-2024.4.20.dist-info/WHEEL,SHA256=1VPi6hfNQaRRNuEdK_3dv9o8COtLGnHWJghhj4CQ28k,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=H73oRFRFBYN84DHbwTg8OH9Dh7VNqFwpMZgFbjEaBcI,16781
4
- json_duplicate_keys-2024.3.24.dist-info/WHEEL,SHA256=1VPi6hfNQaRRNuEdK_3dv9o8COtLGnHWJghhj4CQ28k,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,,