Skip to main content

Budget‑constrained JSON preview renderer (Python bindings)

Project description

headson

Budget‑constrained JSON preview for the terminal.

Install

Using Cargo:

cargo install headson

From source:

cargo build --release
target/release/headson --help

Usage

headson [FLAGS] [INPUT...]
  • INPUT (optional, repeatable): file path(s). If omitted, reads JSON from stdin. Multiple input files are supported.
  • Prints the preview to stdout. On parse errors, exits non‑zero and prints an error to stderr.

Common flags:

  • -n, --budget <BYTES>: per‑file output budget. When multiple input files are provided, the total budget equals <BYTES> * number_of_inputs.
  • -N, --global-budget <BYTES>: total output budget across all inputs. Useful when you want a fixed-size preview across many files (may omit entire files). Mutually exclusive with --budget.
  • -f, --template <json|pseudo|js>: output style (default: pseudo)
  • -m, --compact: no indentation, no spaces, no newlines
  • --no-newline: single line output
  • --no-space: no space after : in objects
  • --indent <STR>: indentation unit (default: two spaces)
  • --string-cap <N>: max graphemes to consider per string (default: 500)

Notes:

  • With multiple input files:
    • JSON template outputs a single JSON object keyed by the input file paths.
    • Pseudo and JS templates render file sections with human-readable headers.
    • Using --global-budget may truncate or omit entire files to respect the total budget.
  • When passing file paths, directories and binary files are ignored; a notice is printed to stderr for each (e.g., Ignored binary file: ./path/to/file). Stdin mode reads the stream as-is.

Examples:

  • Read from stdin with defaults:

    cat data.json | headson
    
  • Read from file, JS style, 200‑byte budget:

    headson -n 200 -f js data.json
    
  • JSON style, compact:

    headson -f json -m data.json
    
  • Multiple files (JSON template produces an object keyed by paths):

    headson -f json a.json b.json
    
  • Global limit across files (fixed total size across all files):

    headson -N 400 -f json a.json b.json
    

Show help:

headson --help

Python package

Headson is also available as a Python extension module built with PyO3/maturin.

Install from PyPI:

pip install headson

Example:

import json
import headson

data = {"foo": [1, 2, 3], "bar": {"x": "y"}}
preview = headson.summarize(json.dumps(data), template="json", character_budget=200)
print(preview)

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

headson-0.2.5.tar.gz (32.5 kB view details)

Uploaded Source

Built Distributions

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

headson-0.2.5-cp312-cp312-win_amd64.whl (219.8 kB view details)

Uploaded CPython 3.12Windows x86-64

headson-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (327.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

headson-0.2.5-cp312-cp312-macosx_11_0_arm64.whl (278.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

headson-0.2.5-cp311-cp311-win_amd64.whl (221.2 kB view details)

Uploaded CPython 3.11Windows x86-64

headson-0.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (328.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

headson-0.2.5-cp311-cp311-macosx_11_0_arm64.whl (279.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

headson-0.2.5-cp310-cp310-win_amd64.whl (221.1 kB view details)

Uploaded CPython 3.10Windows x86-64

headson-0.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (328.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

headson-0.2.5-cp310-cp310-macosx_11_0_arm64.whl (279.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file headson-0.2.5.tar.gz.

File metadata

  • Download URL: headson-0.2.5.tar.gz
  • Upload date:
  • Size: 32.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.9.6

File hashes

Hashes for headson-0.2.5.tar.gz
Algorithm Hash digest
SHA256 1cb2fb45b7ca55b8ddb65ee5551878d304887d646fdcc8d53dee904ff633d496
MD5 ea0b7fa457a5e18938e46e8212f6015a
BLAKE2b-256 0cbb803a583231896dae9096e5aad2c1a83794db96cb2ea4105f1703c1000fa5

See more details on using hashes here.

File details

Details for the file headson-0.2.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: headson-0.2.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 219.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.9.6

File hashes

Hashes for headson-0.2.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d58d4848cd5772cce62a617e1aa33f2242a556f67477ce028cc7260cd598dd51
MD5 479c1546272d72f7e7a9d2fd878f25c2
BLAKE2b-256 849c485b51fb9f7f16eb41a80ba8c34dac6787ca4f1903158c96fdd21c1af40c

See more details on using hashes here.

File details

Details for the file headson-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for headson-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d5598bec44ac62d4378e34341516124c2083db3f5df4f13b21ac3a023af3d879
MD5 8185c9c1581a754efe12f704ca6849d1
BLAKE2b-256 81ef8387159dc3870815de8ea0581e0d91704759ba8e8ecddd2e5a9a51749bf1

See more details on using hashes here.

File details

Details for the file headson-0.2.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for headson-0.2.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2746d99a7324f2a6a33194520a7246583e6fe345e029ce083964eb6c3fb26bf2
MD5 a9fe2c7f6e041f8abb931d86bc70e7e3
BLAKE2b-256 0308b56e1a5680a96e80928c38bc281c3e8b56e0c4eb8d0652d405339f965752

See more details on using hashes here.

File details

Details for the file headson-0.2.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: headson-0.2.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 221.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.9.6

File hashes

Hashes for headson-0.2.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 53bfce8c1e55fa02f2095769b2acf12788bcf142686cc0b77362061b2f260363
MD5 6df3f266715cdc8b484388745453b1df
BLAKE2b-256 5f846b5a3b601564227ca14c07f88c9fcad0468b0a68b382fd09ba835fb99956

See more details on using hashes here.

File details

Details for the file headson-0.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for headson-0.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 df523fbdf9bb150100076be6f39ad83a6aaa1045aa481ad7c291b7c08076f6e1
MD5 fabaaa4052aa83773fff78340e73c04c
BLAKE2b-256 ffa2ee2c50f2cfe542d3fe3fa4a9026a2289a5c0e0034dfef6c99dc26ba1c2c7

See more details on using hashes here.

File details

Details for the file headson-0.2.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for headson-0.2.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b586b64c17f96a1381dab3345cf7a65b71eba3dfdeebf5dde2b1622b76abf0fa
MD5 3059707116b30f46b1ab46b68c5df38f
BLAKE2b-256 6329a18f646ea7e445a69bafca1dffee4bf18360ef3a234fd4069580e525a1b3

See more details on using hashes here.

File details

Details for the file headson-0.2.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: headson-0.2.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 221.1 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.9.6

File hashes

Hashes for headson-0.2.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 87caa447258d0c80591b16e8ed67d8752eaf670fe3130996795d5a7da6d6f820
MD5 42bc066f6fb7ea12558db97a160bf255
BLAKE2b-256 2c9e07adfd82694064c43ddd1cdf5599fbf167c031d137bcec05160d95b205d4

See more details on using hashes here.

File details

Details for the file headson-0.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for headson-0.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3bf225267129bb613f9f9fe002d77bb369013dcd6aa52807844b7426634885d9
MD5 9b3b0fdd6bbdfd6e2fda1dd842126949
BLAKE2b-256 be32a33f8fa3028937602508cb331e5c9157ddc64a99fb3cb58868e0b806f37b

See more details on using hashes here.

File details

Details for the file headson-0.2.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for headson-0.2.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0bd151faaa7de22bbdccab23032fbc08af9c10eb779baf47bf77295291950c84
MD5 049f7e96171475a201025ee62fe83a34
BLAKE2b-256 ac718d2c27f6d0901c24391d0bea367e4faa9a7c847ad1628e47416e7c43d69c

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