Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit 3366b3d

Browse files
committed
Released json-duplicate-keys v2025.6.6
1 parent c8c62b9 commit 3366b3d

File tree

8 files changed

+19
-77
lines changed

8 files changed

+19
-77
lines changed

.github/FUNDING.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
!/requirements.txt
77
!/SECURITY.md
88
!/setup.py
9-
!/json_duplicate_keys/
9+
!/json_duplicate_keys
1010
!/json_duplicate_keys/__init__.py

.readthedocs.yaml

Lines changed: 0 additions & 35 deletions
This file was deleted.

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ print(jdks.normalize_key("version{{{_2_}}}"))
4141
```
4242
---
4343

44-
### loads(`Jstr`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `_isDebug_`=False)
44+
### loads(`Jstr`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `skipDuplicated`=False, `_isDebug_`=False)
4545
_Deserialize a JSON format string to a class `JSON_DUPLICATE_KEYS`_
4646
- `Jstr`: a JSON format string
4747
- `dupSign_start`:
4848
- `dupSign_end`:
4949
- `ordered_dict`: preserves the order in which the Keys are inserted
50+
- `skipDuplicated`: Skip loading duplicate keys to improve execution performance
5051
- `_isDebug_`: Show/ Hide debug error messages
5152
```python
5253
import json_duplicate_keys as jdks
@@ -60,12 +61,13 @@ print(JDKSObject)
6061
```
6162
---
6263

63-
### load(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `_isDebug_`=False)
64+
### load(`Jfilepath`, `dupSign_start`="{{{", `dupSign_end`="}}}", `ordered_dict`=False, `skipDuplicated`=False, `_isDebug_`=False)
6465
_Deserialize a JSON format string from a file to a class `JSON_DUPLICATE_KEYS`_
6566
- `Jfilepath`: The path to the file containing the JSON format string
6667
- `dupSign_start`:
6768
- `dupSign_end`:
6869
- `ordered_dict`: preserves the order in which the Keys are inserted
70+
- `skipDuplicated`: Skip loading duplicate keys to improve execution performance
6971
- `_isDebug_`: Show/ Hide debug error messages
7072
```python
7173
# /path/to/file.json: {"author": "truocphan", "version": "22.3.3", "version": "latest", "release": [{"version": "latest"}], "snapshot": {"author": "truocphan", "version": "22.3.3", "release": [{"version": "latest"}]}}
@@ -414,6 +416,9 @@ print(JDKSObject.getObject())
414416
---
415417

416418
## CHANGELOG
419+
#### [json-duplicate-keys v2025.6.6](https://github.com/truocphan/json-duplicate-keys/tree/2025.6.6)
420+
- [**Updated**] Added `skipDuplicated` parameter to `load` and `loads` functions to improve performance when parsing large JSON strings by skipping duplicate keys.
421+
417422
#### [json-duplicate-keys v2024.12.12](https://github.com/truocphan/json-duplicate-keys/tree/2024.12.12)
418423
- **New**: _insert_ function
419424

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
| Version | Supported |
66
| ------- | ------------------ |
7-
| Latest | :white_check_mark: |
7+
| Latest | :white_check_mark: |
88
| Older | :x: |
99

1010
## Reporting a Vulnerability

json_duplicate_keys/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
json_duplicate_keys_VERSION = "2025.6.6"
23
try:
34
unicode # Python 2
45
except NameError:
@@ -31,7 +32,7 @@ def normalize_key(name, dupSign_start="{{{", dupSign_end="}}}", _isDebug_=False)
3132
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
3233
# # # # # # # # # # # # # # # loads # # # # # # # # # # # # # #
3334
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
34-
def loads(Jstr, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, _isDebug_=False):
35+
def loads(Jstr, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, skipDuplicated=False, _isDebug_=False):
3536
# User input data type validation
3637
if type(_isDebug_) != bool: _isDebug_ = False
3738

@@ -93,6 +94,9 @@ def __convert_Jloads_to_Jobj(Jloads, Jobj):
9394
Jloads = json.loads(Jstr)
9495
if ordered_dict: Jloads = json.loads(Jstr, object_pairs_hook=OrderedDict)
9596

97+
if skipDuplicated:
98+
return JSON_DUPLICATE_KEYS(Jloads)
99+
96100
if type(Jloads) in [list, dict, OrderedDict]:
97101
dupSign_start_escape = "".join(["\\\\u"+hex(ord(c))[2:].zfill(4) for c in dupSign_start])
98102
dupSign_start_escape_regex = re.escape(dupSign_start)
@@ -147,12 +151,12 @@ def __convert_Jloads_to_Jobj(Jloads, Jobj):
147151
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
148152
# # # # # # # # # # # # # # # load # # # # # # # # # # # # # #
149153
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
150-
def load(Jfilepath, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, _isDebug_=False):
154+
def load(Jfilepath, dupSign_start="{{{", dupSign_end="}}}", ordered_dict=False, skipDuplicated=False, _isDebug_=False):
151155
try:
152156
with open(Jfilepath) as Jfile:
153157
Jstr = Jfile.read()
154158

155-
return loads(Jstr, dupSign_start=dupSign_start, dupSign_end=dupSign_end, ordered_dict=ordered_dict, _isDebug_=_isDebug_)
159+
return loads(Jstr, dupSign_start=dupSign_start, dupSign_end=dupSign_end, ordered_dict=ordered_dict, skipDuplicated=skipDuplicated, _isDebug_=_isDebug_)
156160
except Exception as e:
157161
if _isDebug_: print("\x1b[31m[-] ExceptionError: {}\x1b[0m".format(e))
158162
return False

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from json_duplicate_keys import json_duplicate_keys_VERSION
12
import setuptools
23

34
setuptools.setup(
45
name="json-duplicate-keys",
5-
version="2024.12.12",
6+
version=json_duplicate_keys_VERSION,
67
author="TP Cyber Security",
78
license="MIT",
89
author_email="tpcybersec2023@gmail.com",
@@ -17,5 +18,5 @@
1718
"Programming Language :: Python :: Implementation :: Jython"
1819
],
1920
keywords=["TPCyberSec", "json", "duplicate keys", "json duplicate keys", "flatten", "unflatten"],
20-
packages=["json_duplicate_keys"],
21+
packages=setuptools.find_packages(),
2122
)

0 commit comments

Comments
 (0)