JSON file builder
Project description
json-build
Installation
pip install json-build
Create a new JSON object to build upon
from json_build import JSON_Object
new_json = JSON_Object()
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'
)
## 'parent' is optional; if unused, the object will be added to the first layer of the JSON object
## 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="new_config", location_path="C:/Users/fkrueger/Desktop/")
## 'location_path' is optional; if unused 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"
}
}
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
json-build-0.0.24.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for json_build-0.0.24-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42dc252b38d1cf0cdc404603c0838b0457e1d1afcd0e08397341e980d76566ba |
|
MD5 | 881b835174a375429d68959106587a97 |
|
BLAKE2b-256 | 94f4e0f5364b131d6b4544c2383f7af790fcbe0c82fc65928e038d36dfe58f9a |