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

Uploaded Source

Built Distribution

kokojson-0.1.1-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kokojson-0.1.1.tar.gz
  • Upload date:
  • Size: 2.1 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.1.tar.gz
Algorithm Hash digest
SHA256 c02d6461e9422936a0168baed9eb2632a30d434b40517050f6f1a532eba4edcf
MD5 d139e14b9569fe5e0e310adc027d6b53
BLAKE2b-256 ff45dead66094643b0cfafb5f4d842735ff80d53411c70de5c64c7cc0863b53d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kokojson-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 14630ddba14bb51a8832c0d3dd12bf1cffdba47dbfc8550cae655d9b48c14cec
MD5 7dddda1bc959236a27000501296fa72c
BLAKE2b-256 fd146ad5255c472491773581ed59c4baf8bfd04bcaac1257f1df2a75684b7e15

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