json-duplicate-keys 2024.2.3__py3-none-any.whl → 2024.2.21__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.
@@ -444,6 +444,26 @@ class JSON_DUPLICATE_KEYS:
444
444
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
445
445
 
446
446
 
447
+ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
448
+ # # # # # # # # # # # # filter_keys # # # # # # # # # # # # #
449
+ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
450
+ def filter_keys(self, name, separator="||", parse_index="$", ordered_dict=False):
451
+ import re, copy
452
+
453
+ JDKSObject = copy.deepcopy(self)
454
+ JDKSObject.flatten(separator=separator, parse_index=parse_index, ordered_dict=ordered_dict)
455
+ newJDKSObject = loads("{}", ordered_dict=ordered_dict)
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)
460
+
461
+ return newJDKSObject
462
+ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
463
+ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
464
+ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
465
+
466
+
447
467
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
448
468
  # # # # # # # # # # # # # # dumps # # # # # # # # # # # # # #
449
469
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json-duplicate-keys
3
- Version: 2024.2.3
3
+ Version: 2024.2.21
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
7
7
  Author-email: tpcybersec2023@gmail.com
8
8
  License: MIT
9
- Keywords: json,duplicate keys,json duplicate keys,flatten,unflatten
9
+ Keywords: TPCyberSec,json,duplicate keys,json duplicate keys,flatten,unflatten
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 2
12
12
  Classifier: Programming Language :: Python :: Implementation :: Jython
@@ -251,6 +251,27 @@ print(JDKSObject.getObject())
251
251
  ```
252
252
  ---
253
253
 
254
+ ### JSON_DUPLICATE_KEYS.filter_keys(`name`, `separator`="||", `parse_index`="$", `ordered_dict`=False)
255
+
256
+ - `name`:
257
+ - `separator`:
258
+ - `parse_index`:
259
+ - `ordered_dict`:
260
+ ```python
261
+ import json_duplicate_keys as jdks
262
+
263
+ Jstr = '{"author": "truocphan", "version": "22.3.3", "version": "latest", "release": [{"version": "latest"}], "snapshot": {"author": "truocphan", "version": "22.3.3", "release": [{"version": "latest"}]}}'
264
+
265
+ JDKSObject = jdks.loads(Jstr)
266
+
267
+ print(JDKSObject.filter_keys("version").dumps())
268
+ # OUTPUT: {"version": "22.3.3", "version": "latest", "release||$0$||version": "latest", "snapshot||version": "22.3.3", "snapshot||release||$0$||version": "latest"}
269
+
270
+ print(JDKSObject.dumps())
271
+ # OUTPUT: {"author": "truocphan", "version": "22.3.3", "version": "latest", "release": [{"version": "latest"}], "snapshot": {"author": "truocphan", "version": "22.3.3", "release": [{"version": "latest"}]}}
272
+ ```
273
+ ---
274
+
254
275
  ### 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)
255
276
  _Serialize a JSON object to a JSON format string_
256
277
  - `dupSign_start`:
@@ -0,0 +1,6 @@
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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.1)
2
+ Generator: bdist_wheel (0.41.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,6 +0,0 @@
1
- json_duplicate_keys/__init__.py,sha256=s9y6GXxwLvhQ_r1IPDDL71KI6FjqdbULprrha6E5uzI,27662
2
- json_duplicate_keys-2024.2.3.dist-info/LICENSE,sha256=_hudSGMciUc27wGR8EMKfeb3atJRlf6rbhJtLnel-nc,1093
3
- json_duplicate_keys-2024.2.3.dist-info/METADATA,sha256=3If6F58b-gkSzJKPm4xkfjSMlqRdZwWhGSfYBKwZ1ms,16021
4
- json_duplicate_keys-2024.2.3.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
5
- json_duplicate_keys-2024.2.3.dist-info/top_level.txt,sha256=vdsGrPLVS_l-BFL1i4hCJBY5_-gq4Cwp-11yegA750Y,20
6
- json_duplicate_keys-2024.2.3.dist-info/RECORD,,