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

Uploaded Source

Built Distribution

kokojson-0.1.0-py3-none-any.whl (1.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kokojson-0.1.0.tar.gz
  • Upload date:
  • Size: 1.6 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.0.tar.gz
Algorithm Hash digest
SHA256 62b1b86343d9a46416927dab68025f9566e32d9f6b51af047af96e186e0033a8
MD5 b72164b5b95d2d2733b46f589c904f04
BLAKE2b-256 e36f92cfe78d4237413e7c014c55d18bf728b4699cf1c07f9a6f97a04aa6e982

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kokojson-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 1.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f52e3e97908c8428023b37e21d2cdec7bd556b0a1f3d368e2a7e6b625ba27400
MD5 b1f27f97d8c9d100a34bb0fb6a4e5ebd
BLAKE2b-256 b1549d060da87695c44f0ca2ef36a09b15e873bb7038819990f30624513642fe

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