Skip to main content

Efficient JSON flattening for complex nested structures

Project description

jsonxplode

Efficient JSON flattening for complex nested structures

Python Version License Dependencies

jsonxplode converts nested JSON structures into flat tabular format while preserving all data, including complex nested arrays and objects with arbitrary depth.

Installation

pip install jsonxplode

Usage

from jsonxplode import flatten

# Handles any JSON structure
data = {
    "users": [
        {"profile": {"name": "John", "settings": {"theme": "dark"}, "location": ["city1", "city2"]}},
        {"profile": {"name": "Jane", "settings": {"theme": "light"}}}
    ]
}

flattened_data = flatten(data)

Returns:

[
    {'users.profile.name': 'John', 'users.profile.settings.theme': 'dark', 'user.profile.location': 'city1'},
    {'users.profile.name': 'John', 'users.profile.settings.theme': 'dark', 'user.profile.location': 'city2'},
    {'users.profile.name': 'Jane', 'users.profile.settings.theme': 'light'}
]

DataFrame Output (Optional)

from jsonxplode import to_dataframe

# Requires pandas to be installed separately
df = to_dataframe(data)

Note: to_dataframe requires pandas (pip install pandas) but the core flatten function has zero dependencies.

Features

  • Arbitrary nesting depth - handles deeply nested objects and arrays
  • Conflict resolution - automatically manages key path conflicts
  • Memory efficient - processes large datasets with minimal overhead
  • Zero dependencies - pure Python implementation (core function)
  • Array expansion - properly handles nested arrays with row duplication

Performance

  • 7,900 rows with 23 columns processed in 0.146 seconds
  • Memory usage: ~16MB for above mentioned workload
  • Consistent performance across varying data structures

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

jsonxplode-1.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsonxplode-1.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file jsonxplode-1.1.0.tar.gz.

File metadata

  • Download URL: jsonxplode-1.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for jsonxplode-1.1.0.tar.gz
Algorithm Hash digest
SHA256 d87ec1cb171e9aedf40beb12e537015f5dc1783ea8e87b2e9b98388218e8403e
MD5 513e31c669b1fd4f0ae2e7b47d999ac1
BLAKE2b-256 7afa9f2017b809f6dc062fd529b69d62f4a889a3118aad34bd29a13ca12296ac

See more details on using hashes here.

File details

Details for the file jsonxplode-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: jsonxplode-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for jsonxplode-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6955a884756d1d2204af560a088a858acd03ea00b3b4d10537fe6968b362673f
MD5 be3cbfc4a1c627f38df3e1b5f93c7f31
BLAKE2b-256 7d87ebcd20ae15295cda03e2831f6015f6ae391110d49d0ab5cb9d697ac1ccab

See more details on using hashes here.

Supported by

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