Skip to main content

Python tools for JSONC and JSON5 (aka. JSON for humans)

Project description

json4humans

CI pre-commit.ci status Maintainability Test Coverage Documentation Status

Python tools for JSONC and JSON5 (aka. JSON for humans)

This package provider parsing and serialization (with style preservation) as well as linting, formatting and cli tools for JSON-derived syntaxes.

Getting started

Add json4humans as a dependency to your project:

# pip
pip install json4humans
# pipenv
pipenv install json4humans
# PDM
pdm add json4humans

Then import the proper module and use it like you would with the builtin json module:

from pathlib import Path
from json4humans import json

my_file = Path(__file__).parent / "my_file.json"

# Load data
with my_file.open() as f:
    data = json.load(f)

# Edit
data["attr"] = "value"

# Save with style preservation
with my_file.open("w") as out:
    json.dump(out, data)

Features

  • Manipulate all supported format with the exact same API. Currently supported:
  • Parsed data supports native types comparison while preserving style
  • Support serialization for both native types and provided JSONType
  • Supports formatting
  • Supports linting
  • All features availables as a standalone cli
  • Support jq-like queries

Documentation

Documentation is available at https://json4humans.rtfd.io

Contributing

Read the dedicated contributing guidelines.

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

json4humans-0.1.0.tar.gz (16.3 kB view hashes)

Uploaded Source

Built Distribution

json4humans-0.1.0-py3-none-any.whl (14.3 kB view hashes)

Uploaded Python 3

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