Skip to main content

JSON file builder

Project description

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"
        ]
    }
]

Project details


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-1.0.12.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

json_build-1.0.12-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file json-build-1.0.12.tar.gz.

File metadata

  • Download URL: json-build-1.0.12.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for json-build-1.0.12.tar.gz
Algorithm Hash digest
SHA256 6f4b29426fd6e99370a5db18429daf804944446ac5add4eeaef4f277523f9671
MD5 47caf89914af7ea3bc593950e8f4056e
BLAKE2b-256 5a3d44b83d8b0f297ed3dc37dae5d75630dc5782d6a017955ea074c247c26325

See more details on using hashes here.

File details

Details for the file json_build-1.0.12-py3-none-any.whl.

File metadata

  • Download URL: json_build-1.0.12-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for json_build-1.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 813bcfed8ffe4eb46cb347fb7f287657a908f7b6291bb163e4fe99d35dfb6ea4
MD5 07b3ff96006732973e57435df7e21888
BLAKE2b-256 77d354d3dfbee5ec58fa2dfcb7f5b50f3d56785bb619c5efb9c0d0262d7fce92

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page