json-duplicate-keys 2024.2.3__tar.gz → 2024.2.21__tar.gz

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.
@@ -1,6 +1,6 @@
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
@@ -244,6 +244,27 @@ Description: # JSON Duplicate Keys
244
244
  ```
245
245
  ---
246
246
 
247
+ ### JSON_DUPLICATE_KEYS.filter_keys(`name`, `separator`="||", `parse_index`="$", `ordered_dict`=False)
248
+
249
+ - `name`:
250
+ - `separator`:
251
+ - `parse_index`:
252
+ - `ordered_dict`:
253
+ ```python
254
+ import json_duplicate_keys as jdks
255
+
256
+ Jstr = '{"author": "truocphan", "version": "22.3.3", "version": "latest", "release": [{"version": "latest"}], "snapshot": {"author": "truocphan", "version": "22.3.3", "release": [{"version": "latest"}]}}'
257
+
258
+ JDKSObject = jdks.loads(Jstr)
259
+
260
+ print(JDKSObject.filter_keys("version").dumps())
261
+ # OUTPUT: {"version": "22.3.3", "version": "latest", "release||$0$||version": "latest", "snapshot||version": "22.3.3", "snapshot||release||$0$||version": "latest"}
262
+
263
+ print(JDKSObject.dumps())
264
+ # OUTPUT: {"author": "truocphan", "version": "22.3.3", "version": "latest", "release": [{"version": "latest"}], "snapshot": {"author": "truocphan", "version": "22.3.3", "release": [{"version": "latest"}]}}
265
+ ```
266
+ ---
267
+
247
268
  ### 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)
248
269
  _Serialize a JSON object to a JSON format string_
249
270
  - `dupSign_start`:
@@ -344,7 +365,7 @@ Description: # JSON Duplicate Keys
344
365
  # OUTPUT: {'author': 'truocphan', 'version': '22.3.3', 'version{{{_2_}}}': 'latest', 'release': [{'version': 'latest'}], 'snapshot': {'author': 'truocphan', 'version': '22.3.3', 'release': [{'version': 'latest'}]}}
345
366
  ```
346
367
  ---
347
- Keywords: json,duplicate keys,json duplicate keys,flatten,unflatten
368
+ Keywords: TPCyberSec,json,duplicate keys,json duplicate keys,flatten,unflatten
348
369
  Platform: UNKNOWN
349
370
  Classifier: Programming Language :: Python :: 3
350
371
  Classifier: Programming Language :: Python :: 2
@@ -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
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -2,7 +2,7 @@ import setuptools
2
2
 
3
3
  setuptools.setup(
4
4
  name="json-duplicate-keys",
5
- version="2024.2.3",
5
+ version="2024.2.21",
6
6
  author="TP Cyber Security",
7
7
  license="MIT",
8
8
  author_email="tpcybersec2023@gmail.com",
@@ -16,6 +16,6 @@ setuptools.setup(
16
16
  "Programming Language :: Python :: 2",
17
17
  "Programming Language :: Python :: Implementation :: Jython"
18
18
  ],
19
- keywords=["json", "duplicate keys", "json duplicate keys", "flatten", "unflatten"],
19
+ keywords=["TPCyberSec", "json", "duplicate keys", "json duplicate keys", "flatten", "unflatten"],
20
20
  packages=["json_duplicate_keys"],
21
21
  )