
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
A specialized dictionary unpacking tool that allows you to expand a dictionary by unpacking internal arrays or list values, generating a list of dictionaries. Each dictionary in the list will contain a copy of all key-value pairs. This tool is designed to split arrays within JSON data into multiple records, making it easier to insert into a database.
A specialized dictionary splitting tool that allows you to unpack a dictionary from its internal array or list values and generate a list. Each list will have a complete copy of all key-value pairs. It's somewhat similar to a matrix. This tool is designed to split arrays within JSON data into multiple records, making it easier to insert into a database.
data = {
"id": 1,
"name": "John",
"subject": [{"id": 22, "des": "math"}, {"id": 23, "des": "art"}]
}
Allow overriding parent's same-named key-value pairs by default.
unpack(data, ["subject"])
Output:
[{'id': 22, 'name': 'John', 'des': 'math'},
{'id': 23, 'name': 'John', 'des': 'art'}]
Forbid overriding parent's same-named key-value pairs.
unpack(data, ["subject"], ".")
Output:
[{'id': 1, 'name': 'John', 'subject.id': 1, 'subject.name': 'John'},
{'id': 1, 'name': 'John', 'subject.id': 1, 'subject.name': 'John'}]
An empty list will be returned when a non-existent path is passed in.
unpack(data, ["subject", "name"], ".")
Output:
[]
data = {
"id": 1,
"name": "John",
"subject": [{
"subjectid": 22,
"des": [{"key": "a"},
{"key": "b"}]
}, {"subjectid": 23,
"des": [{"key": "a"},
{"key": "e"}]
}]
}
unpack(data, ["subject"])
Output:
[
{'id': 1, 'name': 'John', 'subjectid': 22, 'des': [{'key': 'a'}, {'key': 'b'}]},
{'id': 1, 'name': 'John', 'subjectid': 23, 'des': [{'key': 'a'}, {'key': 'e'}]}
]
unpack(data, ["subject", "des"])
Output:
[
{'id': 1, 'name': 'John', 'subjectid': 22, 'key': 'a'},
{'id': 1, 'name': 'John', 'subjectid': 22, 'key': 'b'},
{'id': 1, 'name': 'John', 'subjectid': 23, 'key': 'a'},
{'id': 1, 'name': 'John', 'subjectid': 23, 'key': 'e'}
]
If it is empty, override the same-named key-value pairs in the parent. If it is not empty, use the provided string as the delimiter to connect with the parent key.
unpack(data, ["subject", "des"], "_")
Output:
[
{'id': 1, 'name': 'John', 'subject_subjectid': 22, 'subject_des_key': 'a'},
{'id': 1, 'name': 'John', 'subject_subjectid': 22, 'subject_des_key': 'b'},
{'id': 1, 'name': 'John', 'subject_subjectid': 23, 'subject_des_key': 'a'},
{'id': 1, 'name': 'John', 'subject_subjectid': 23, 'subject_des_key': 'e'}
]
unpack(
dictionary = {"id": 1, "name": "John", "grades": [85, 92, 78]},
index = ["grades"],
delimiter = None
)
Array-type fields only allow single-level unpacking.
Output:
[
{"id": 1, "name": "John", "grade": 85},
{"id": 1, "name": "John", "grade": 92},
{"id": 1, "name": "John", "grade": 78}
]
FAQs
A specialized dictionary unpacking tool that allows you to expand a dictionary by unpacking internal arrays or list values, generating a list of dictionaries. Each dictionary in the list will contain a copy of all key-value pairs. This tool is designed to split arrays within JSON data into multiple records, making it easier to insert into a database.
We found that dict-unpack demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.