Skip to main content

Manipulate JSON data or dict values as attributes of an object.

Project description

JSON Handler

It's easy-to-use library which helps you to work with data in JSON files and Python dictionaries like if they were Python objects.

Examples

Example 1.

You can easily read existing JSON file and modify it. Here is JSON file (example.json):

{
    "field_1": "Hi",
    "field_2": "Hello world!",
    "field_3": {
        "sub_field": 123
    }
}

We can modify the content of that by using following code:

from json_handler import JsonHandler

handler = JsonHandler('example.json')

handler.field_1 = 123
handler['field_2'] = "What's up?"
handler.sub_field = [1, 2, 3]

handler.save()

The result of modifications will be (example.json):

{
    "field_1": 123,
    "field_2": "What's up?",
    "field_3": {
        "sub_field": [1, 2, 3]
    }
}

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_handler-1.0.1.tar.gz (2.9 kB view hashes)

Uploaded Source

Supported by

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