Skip to main content

A module for safe JSON handling in Python

Project description

A module for safe JSON handling in Python

Example Usage:

data.json:

{
  "person": {
    "name": "John Doe",
    "age": 30,
    "city": "New York"
  },
  "company": {
    "name": "Acme Inc.",
    "employees": 500
  }
}
import kokojson as json1

# Load the JSON data from the file
with open("data.json", "r") as file:
    data = file.read()

# Parse the JSON data using kokojson
json_data = json1.load(data)

# Access existing keys
print(json_data.get("person").get("name"))  # Output: John Doe
print(json_data.get("company").get("employees"))  # Output: 500

# Access non-existing keys (returns None instead of raising an exception)
print(json_data.get("person").get("email"))  # Output: None
print(json_data.get("company").get("website"))  # Output: None

# Provide a default value for non-existing keys
print(json_data.get("person").get("email", "No email found"))  # Output: No email found
print(json_data.get("company").get("website", "https://example.com"))  # Output: https://example.com

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

kokojson-0.1.5.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

kokojson-0.1.5-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file kokojson-0.1.5.tar.gz.

File metadata

  • Download URL: kokojson-0.1.5.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.3

File hashes

Hashes for kokojson-0.1.5.tar.gz
Algorithm Hash digest
SHA256 38b8462da7279e5a7b2638601692a54792ab76b49424fdb8f968b8de44b65943
MD5 2c588eafd65ae399ea2466cf16dce4f3
BLAKE2b-256 7fe8f2325b4e1ef65141ad4d9b0a299735f2fa379927deab4025f1ecf86becda

See more details on using hashes here.

File details

Details for the file kokojson-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: kokojson-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.3

File hashes

Hashes for kokojson-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 67f9e2909e3d83c3fdccf56558975d1dacc136c2a4ec5793d62c2fdcaf218865
MD5 30c59496368a66f3a9553b0726fa4b9e
BLAKE2b-256 d8e012c8e4ce118817e37569c366a40ce2bb05ead7d947030264943a20a5a661

See more details on using hashes here.

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