Name | json-build JSON |
Version |
1.0.9
JSON |
| download |
home_page | |
Summary | JSON file builder |
upload_time | 2023-11-14 06:16:17 |
maintainer | |
docs_url | None |
author | Vince Berry |
requires_python | |
license | |
keywords |
python
json
build
config
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# json-build
json-build is a package that allows developers to build and save JSON files quickly.
## Installation
```python
pip install json-build
```
## Create a new JSON object to build upon
```python
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
```python
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
```python
new_json.create()
```
## Save the JSON object to a file
```python
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
```json
[
{
"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"
]
}
]
```
Raw data
{
"_id": null,
"home_page": "",
"name": "json-build",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python,json,build,config",
"author": "Vince Berry",
"author_email": "vincent.berry11@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3e/5c/b89550883322204176d3f87de20d20179f52bfe57cdc9e022c05b1448123/json-build-1.0.9.tar.gz",
"platform": null,
"description": "\n# json-build\n\njson-build is a package that allows developers to build and save JSON files quickly.\n\n## Installation\n\n```python\npip install json-build\n```\n\n## Create a new JSON object to build upon\n\n```python\nfrom json_build import JSON_Object\n\nnew_json = JSON_Object(outer=[])\n\n# 'outer' argument is optional\n# if 'outer=[]' is passed it will wrap the JSON object in an array (Python list)\n# otherwise, it will be a JSON object (Python dictionary)\n```\n\n## Nest objects inside the JSON object\n\n```python\nnew_json.add_object(\n unique_name=\"people\", \n keyword=\"people\", \n data={},\n )\n\nnew_json.add_object(\n unique_name = 'person_1',\n keyword = 'person1',\n data = {\"first_name\": \"Michael\", \"last_name\": \"Myers\"},\n parent='people',\n)\n\nnew_json.add_object(\n unique_name = 'relative_1',\n keyword = 'relative',\n data = {\"first_name\": \"Laurie\", \"last_name\": \"Strode\", \"relation\": \"Sister\"},\n parent = 'person_1'\n)\n\nnew_json.add_object(\n unique_name = 'person_2',\n keyword = 'person2',\n data = {\"first_name\": \"Jason\", \"last_name\": \"Voorhees\"},\n parent='people',\n)\n\nnew_json.add_object(\n unique_name = 'relative_2',\n keyword = 'relative',\n data = {\"first_name\": \"Pamela\", \"last_name\": \"Voorhees\", \"relation\": \"Mother\"},\n parent = 'person_2'\n)\n\nnew_json.add_object(\n unique_name = 'movies',\n keyword = 'movies',\n data = [\n 'Halloween',\n 'Friday the 13th',\n 'Nightmare on Elm Street',\n ],\n)\n\n# 'parent' argument is optional; if unpassed, the object will be added to the JSON object's first level\n# Note that 'parent' uses the unique_name of the parent object, and not the keyword\n```\n\n## Create the JSON object\n\n```python\nnew_json.create()\n```\n\n## Save the JSON object to a file\n\n```python\nnew_json.save(file_name=\"killer_names\", location_path=\"C:/Users/fkrueger/Desktop/\")\n\n# 'location_path' argument is optional; if unpassed it will save the file to the root of your local project\n```\n\n## Resultant JSON object\n```json\n[\n {\n \"people\": {\n \"person1\": {\n \"first_name\": \"Michael\",\n \"last_name\": \"Myers\",\n \"relative\": {\n \"first_name\": \"Laurie\",\n \"last_name\": \"Strode\",\n \"relation\": \"Sister\"\n }\n },\n \"person2\": {\n \"first_name\": \"Jason\",\n \"last_name\": \"Voorhees\",\n \"relative\": {\n \"first_name\": \"Pamela\",\n \"last_name\": \"Voorhees\",\n \"relation\": \"Mother\"\n }\n }\n },\n \"movies\": [\n \"Halloween\",\n \"Friday the 13th\",\n \"Nightmare on Elm Street\"\n ]\n }\n]\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "JSON file builder",
"version": "1.0.9",
"project_urls": null,
"split_keywords": [
"python",
"json",
"build",
"config"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b65fc1da4a9b248057c934632ab0208619dcd09b92d24a4f4b5bfd515e9cfefc",
"md5": "a0d2671452f84846efad3bafdcea60b1",
"sha256": "62239f92eaca2147dbd97200db473bb79aa4be3eb4b8dc3bcb10f1550a618580"
},
"downloads": -1,
"filename": "json_build-1.0.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a0d2671452f84846efad3bafdcea60b1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4688,
"upload_time": "2023-11-14T06:16:15",
"upload_time_iso_8601": "2023-11-14T06:16:15.532618Z",
"url": "https://files.pythonhosted.org/packages/b6/5f/c1da4a9b248057c934632ab0208619dcd09b92d24a4f4b5bfd515e9cfefc/json_build-1.0.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3e5cb89550883322204176d3f87de20d20179f52bfe57cdc9e022c05b1448123",
"md5": "b7adb3704e23bd2d8d0b16a9a5d1935c",
"sha256": "ae0c6d183aa624785ecddb054c34b10f407a5710a9e4bc1b7cfda75650406a1b"
},
"downloads": -1,
"filename": "json-build-1.0.9.tar.gz",
"has_sig": false,
"md5_digest": "b7adb3704e23bd2d8d0b16a9a5d1935c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4483,
"upload_time": "2023-11-14T06:16:17",
"upload_time_iso_8601": "2023-11-14T06:16:17.070457Z",
"url": "https://files.pythonhosted.org/packages/3e/5c/b89550883322204176d3f87de20d20179f52bfe57cdc9e022c05b1448123/json-build-1.0.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-14 06:16:17",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "json-build"
}