json-build
json-build is a package that allows developers to build and save JSON files quickly.
Installation
pip install json-build
Create a new JSON object to build upon
from json_build import JSON_Object
new_json = JSON_Object(outer=[])
# 'outer' argument is optional
# if 'outer=[]' is passed it will wrap the JSON object in an array (Python list)
# otherwise, it will be a JSON object (Python dictionary)
Nest objects inside the JSON object
new_json.add_object(
unique_name="people",
keyword="people",
data={},
)
new_json.add_object(
unique_name = 'person_1',
keyword = 'person1',
data = {"first_name": "Michael", "last_name": "Myers"},
parent='people',
)
new_json.add_object(
unique_name = 'relative_1',
keyword = 'relative',
data = {"first_name": "Laurie", "last_name": "Strode", "relation": "Sister"},
parent = 'person_1'
)
new_json.add_object(
unique_name = 'person_2',
keyword = 'person2',
data = {"first_name": "Jason", "last_name": "Voorhees"},
parent='people',
)
new_json.add_object(
unique_name = 'relative_2',
keyword = 'relative',
data = {"first_name": "Pamela", "last_name": "Voorhees", "relation": "Mother"},
parent = 'person_2'
)
new_json.add_object(
unique_name = 'movies',
keyword = 'movies',
data = [
'Halloween',
'Friday the 13th',
'Nightmare on Elm Street',
],
)
# 'parent' argument is optional; if unpassed, the object will be added to the JSON object's first level
# Note that 'parent' uses the unique_name of the parent object, and not the keyword
Create the JSON object
new_json.create()
Save the JSON object to a file
new_json.save(file_name="killer_names", location_path="C:/Users/fkrueger/Desktop/")
# 'location_path' argument is optional; if unpassed it will save the file to the root of your local project
Resultant JSON object
[
{
"people": {
"person1": {
"first_name": "Michael",
"last_name": "Myers",
"relative": {
"first_name": "Laurie",
"last_name": "Strode",
"relation": "Sister"
}
},
"person2": {
"first_name": "Jason",
"last_name": "Voorhees",
"relative": {
"first_name": "Pamela",
"last_name": "Voorhees",
"relation": "Mother"
}
}
},
"movies": [
"Halloween",
"Friday the 13th",
"Nightmare on Elm Street"
]
}
]
Metadata
Release files for json-build 1.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| json-build-1.0.12.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| json_build-1.0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.4 kB
Release files / json-build-1.0.12.tar.gz
| Download URL | json-build-1.0.12.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f4b29426fd6e99370a5db18429daf804944446ac5add4eeaef4f277523f9671
|
|
BLAKE2b-256 checksum How to use checksums |
5a3d44b83d8b0f297ed3dc37dae5d75630dc5782d6a017955ea074c247c26325
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / json_build-1.0.12-py3-none-any.whl
| Download URL | json_build-1.0.12-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
813bcfed8ffe4eb46cb347fb7f287657a908f7b6291bb163e4fe99d35dfb6ea4
|
|
BLAKE2b-256 checksum How to use checksums |
77d354d3dfbee5ec58fa2dfcb7f5b50f3d56785bb619c5efb9c0d0262d7fce92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|