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.4.tar.gz (35.0 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.4-cp312-cp312-win_amd64.whl (210.8 kB view details)

Uploaded CPython 3.12Windows x86-64

headson-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (315.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

headson-0.2.4-cp312-cp312-macosx_11_0_arm64.whl (265.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

headson-0.2.4-cp311-cp311-win_amd64.whl (210.9 kB view details)

Uploaded CPython 3.11Windows x86-64

headson-0.2.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (315.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

headson-0.2.4-cp311-cp311-macosx_11_0_arm64.whl (265.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

headson-0.2.4-cp310-cp310-win_amd64.whl (210.9 kB view details)

Uploaded CPython 3.10Windows x86-64

headson-0.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (315.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

headson-0.2.4-cp310-cp310-macosx_11_0_arm64.whl (265.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for headson-0.2.4.tar.gz
Algorithm Hash digest
SHA256 dac33d629962479e7a0f7a175c77bb7ba10169bd1f420c128a56decf89fade74
MD5 c46126565f76a1677a2d96077cae5ff6
BLAKE2b-256 ff7e4971d1cb6ec295e9dc7a3a4f6a5148a9966b5f0295da5365a35ab074f465

See more details on using hashes here.

File details

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

File metadata

  • Download URL: headson-0.2.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 210.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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c2adc459319ef2f2522e00f41e76257199b71ede1c69983e95234a1283383961
MD5 0dbafd8e3858e940dcd4448c2d32a18b
BLAKE2b-256 3ec0877c31a9094fad68f1128f3b60958a3fb57c12d6ef8e2b9ed3eb0b7f4431

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 525460767dd4d49dc77a2d521890450d00f4ca81d9c8de594616d6f8238324b6
MD5 85e867792184be9e748c2440dc9b0e86
BLAKE2b-256 537ba41ece1c24f4d1272fe4713f708764df4eccb29bacbb54adc5412331fdd8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e4c251a9125da1d21af4132ddc763f6d48ca303911671a4faa6711f3a949bde6
MD5 580d1f0ffe55e4d5066ab178946b039f
BLAKE2b-256 c07c77e5aa0b3e63fd477ee118d8eb58dd76bc958591f4aa77660fcff169b38f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: headson-0.2.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 210.9 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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c8495f95d4fe61d9d4000ec4defa90f957af7feeb3edbc73f6759f644d63d304
MD5 dca70a78119ad4dccb7a99261408d721
BLAKE2b-256 8bd4e9ecff5be9308a6e87a51525d8a03764b8c5e508eaf10082529a29e9d0ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 143d39e22152f50061533e6d6c3ff86f0f90fbb978c555bb319b7871ed110fc7
MD5 862f80f19d57c417e0b36bfd399ecccb
BLAKE2b-256 f9bb96a1e75146ef87038ba3ed8a52df79391b866896ad0831653ce188838b40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5efe0974775a1b717e66410aa5701217ce58c0ac22b040acab948075e091c0df
MD5 f48621e07cb15cfacb1032f100af1b2f
BLAKE2b-256 f5b74e2482c5fdfbef24aa767435a838b33ba72dba1320c4c765f4df6b2f9d27

See more details on using hashes here.

File details

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

File metadata

  • Download URL: headson-0.2.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 210.9 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.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 38b0c40044815039459e3a523b27c38cd100b1575374743dfca6adb34adbc78d
MD5 52540852353f85073d1c3a8da8c83d93
BLAKE2b-256 9a8f1b9ae24f07992fde6c201f041d6bb38b8bcc7f794ac0a6b3471a35971577

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d8c1eb256a87e60c317bfb4b5ca21682ebfb31da54e1a6902931ac7be781fff3
MD5 c1a1825d39e6b1a28763033b93a3b9e3
BLAKE2b-256 0f8e62167f26a59023cc936ecdfcd3ef06213dcc040196fec5ee5669f4075122

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bc5c0803d50503a6f4ad533123e3df0e0a130a3f46b7ed56ba73e2b0db74dcdd
MD5 1437baf96eccc998465a49bb95bc765d
BLAKE2b-256 4e7e0fb3c09739a96cd0b5893017a67701c4133610d160ad16c788bc11b73a0c

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