A small Python package for cleaning, validating, inspecting, comparing, and converting JSON-like data.
Project description
altrepo-json
A small Python package for cleaning, validating, inspecting, comparing, and converting JSON-like data.
Installation
You can install this package locally for testing:
pip install -e .
Features
- Validate: Check if data is valid JSON or conforms to expected basic shapes.
- Format: Pretty-print or minify JSON strings.
- Inspect: Analyze JSON structures to get depths, leaf nodes, or paths.
- Flatten: Flatten nested dictionaries into single-level maps with dotted keys, and unflatten them.
- Path: Retrieve or set values inside deep JSON structures using dot-notation paths.
- Diff: Compare two JSON objects and find differences.
Usage
from altrepo_json import flatten, unflatten, diff, path
# Flattening
data = {"user": {"profile": {"name": "Alice"}}}
flat_data = flatten(data)
# {'user.profile.name': 'Alice'}
# Path access
value = path.get_by_path(data, "user.profile.name")
# 'Alice'
# Diff
data2 = {"user": {"profile": {"name": "Bob", "age": 30}}}
differences = diff.diff(data, data2)
# {'modified': {'user.profile.name': ('Alice', 'Bob')}, 'added': {'user.profile.age': 30}}
Browser version
AltRepo JSON is part of the AltRepo tool ecosystem.
Use the browser-based JSON tools here: https://altrepo.net/dev/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file altrepo_json-0.1.1.tar.gz.
File metadata
- Download URL: altrepo_json-0.1.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c70c7502a65f1c82e7676cb694c27f54dfe45994d8c94fb0aaa0e6181963003
|
|
| MD5 |
1cd76484379aa7f3ba6848cc1e72b372
|
|
| BLAKE2b-256 |
7170ef5e3b3337ab7b3e9b0a722da51fc4433d2b61238a4b5ac122ebd8e0889c
|
File details
Details for the file altrepo_json-0.1.1-py3-none-any.whl.
File metadata
- Download URL: altrepo_json-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ffd536d4976e72968d8ed10d3d369fb6701c1b2a4b1c9af33a013bdb088dd80
|
|
| MD5 |
227a9b7810a9d268021462bdf056a8ae
|
|
| BLAKE2b-256 |
de1de4994997d20fd173a8dd77657c5cc9aa143f9d7325b6027fa6776ce0eaaf
|