Skip to main content

jsonobjectify

A lightweight Python library for converting JSON data into Python objects, simplifying access to nested structures through intuitive dot notation.

Overview

Working with complex JSON data often involves repetitive dictionary lookups, especially when accessing deeply nested structures. jsonobjectify simplifies this process by converting JSON data into Python objects, allowing you to access JSON properties using familiar attribute notation.

Instead of writing chained dictionary lookups, you can navigate nested JSON structures using a clean, readable, object-oriented interface.

Features

  • Dot-notation access: Access JSON properties using Python attributes.
  • Nested object support: Navigate deeply nested JSON structures naturally.
  • List support: Work with collections of JSON objects.
  • Dictionary conversion: Convert mapped objects back into standard Python dictionaries.
  • JSON serialization: Serialize objects back into JSON.
  • Simple API: Keep your code readable when working with complex JSON responses.

Installation

pip install jsonobjectify

Usage

Consider the following JSON data representing an employee and their department:

response = """{
    "id": 1,
    "name": "Michael Anderson",
    "email": "michael.anderson@example.com",
    "website": "www.example.dev",
    "address": {
      "city": "Austin",
      "state": "TX",
      "country": "United States",
      "geo_location": {"lat": "30.2672", "lng": "-97.7431"}
    },
    "skills": [
      {"name": "Python", "level": "Advanced"},
      {"name": "C", "level": "Advanced"},
      {"name": "C++", "level": "Intermediate"}
    ]
}"""

With jsonobjectify, you can access the data through object attributes rather than repeated dictionary lookups.

from jsonobjectify import JsonPath

employee = JsonPath.from_json_string(response)

print(employee.name)
print(employee.address.city)
print(employee.skills[0].name)
print(employee.skills[1].level)

Output

'Michael Anderson'
'Austin'
'Python'
'Advanced'

The example above illustrates the intended API. Adjust the import and construction methods to match the implementation in your repository.

Converting Objects Back to JSON

jsonobjectify is intended to support conversion back to standard Python dictionaries and JSON strings, making it convenient to work with transformed data.

# Convert the object to a Python dictionary
data = employee.to_dict()

# Serialize the object to a JSON string
json_data = employee.to_json()

Requirements

  • Python 3.9 or later

Contributing

Contributions, bug reports, and feature suggestions are welcome. Please open an issue to discuss a proposed change before submitting a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for jsonobjectify 0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonobjectify 0.0.0
File Size Uploaded
jsonobjectify-0.0.0.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonobjectify 0.0.0
File Interpreter ABI Platform
jsonobjectify-0.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / jsonobjectify-0.0.0.tar.gz

Download URL jsonobjectify-0.0.0.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3c0fededb5b4d712ebc1a35c09c59f66962c9a21e5ff05d047c88749dc50cf3f
BLAKE2b-256 checksum
How to use checksums
317e32ffd28ff1103310c548553a5da4325c24474ce9c683337f8dc9c1f5b77c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / jsonobjectify-0.0.0-py3-none-any.whl

Download URL jsonobjectify-0.0.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a74fec18524b93b9e27102245a8541695779ed28b75d24c2097059e1ae7a438
BLAKE2b-256 checksum
How to use checksums
db39e76ccff653ae5055e0ffec5c5561ab2c46cb67a162ea487fad3fcfb6806b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

This release

0.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page