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.

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.3.tar.gz (33.3 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.3-cp312-cp312-win_amd64.whl (210.7 kB view details)

Uploaded CPython 3.12Windows x86-64

headson-0.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (315.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

headson-0.2.3-cp312-cp312-macosx_11_0_arm64.whl (265.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

headson-0.2.3-cp311-cp311-win_amd64.whl (210.8 kB view details)

Uploaded CPython 3.11Windows x86-64

headson-0.2.3-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.3-cp311-cp311-macosx_11_0_arm64.whl (265.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

headson-0.2.3-cp310-cp310-win_amd64.whl (210.8 kB view details)

Uploaded CPython 3.10Windows x86-64

headson-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (315.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

headson-0.2.3-cp310-cp310-macosx_11_0_arm64.whl (265.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for headson-0.2.3.tar.gz
Algorithm Hash digest
SHA256 36d0c47644b085a64662d91d2168bc12ca2234a07e3e9cf2982ef5426317e3b3
MD5 907b084d74b3df4ea4dbb3417cd57314
BLAKE2b-256 fdf7878b93901e2cb62d7749a89f7af0eee944b96a40a0bf05034552faabf07f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: headson-0.2.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 210.7 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cc3bc0697ccaed55f39781bc6ab90b66c9be56e39e2148c7f0471842e135cfe0
MD5 feccb7810332c843fbe574190d84f712
BLAKE2b-256 2d60fb58c37a49df6ae5797051e7676c51131406e288f51e92c33fdc7ce8d19a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6cd2748d24ec9a8b4e0a73590251ca3d3ad28159b8d67e6e1f54f190db94c7b5
MD5 bfc6365ec4a3054293ba9813f6337a31
BLAKE2b-256 ceb70bf6e17b1ae17015e15201036daa3af442340b1d22586412156b7d0b5a05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f132c78f8f45e1b1c3ba2c00b6b8048ffb7fd74e62e6390c7e381d2e4088c5fe
MD5 93c2b3e2ed1e8bb22776f9e489c35a00
BLAKE2b-256 7ddaf989b8190543be96a3b73f68769ec4b75f373ccb43c1efa07b432ab1b9c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: headson-0.2.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 210.8 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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f59f6c990c565dfb0e9647089da56c5e21cebcaf5c66c7649eb9b2091c79b0d0
MD5 e69023b24427bacc85eaacadcfffbdeb
BLAKE2b-256 110ea91ea47325138b71e7c130807f2f2bc0f2bc56b1685428a1480fd9643eb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c6ff4b0376abecb32a24b22ddf0559ebd42d913b20061f0f21d7da421fccd1f
MD5 67d8e97158d610a0078c540e0b7f454d
BLAKE2b-256 c6aa855f78c83626740ec80c424b34cb4df8fae261cfd0453d379f7622bd59d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d2ab58e0eb5e15cd3bd3a0b06b1ca1808605964f981c043d02e802b7d1c8986
MD5 78d91e30330b4e31469d5dabf49ddd13
BLAKE2b-256 930f3c7ff669bec45ed5ac2ff2fdbc5b9e0a2b061ccaff3b80553b3ac932d3fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: headson-0.2.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 210.8 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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b18e910b27d7f103a1612d5cfec9281850caa97093c7b258b7a098949c467cab
MD5 cddefe2057aa48303d72cb1989003c15
BLAKE2b-256 f9fb30694d8387434dd41d928e6b1b6835b7fa3bcccf1fd03ce5a772a04762b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 82c8bf806a1b9f1be00e4752a6ded4903f54ecda34bf95f58468f9b3d8dc6ddd
MD5 b8cbe85af3efd77e791b717220aea201
BLAKE2b-256 90021bbf6b9edabd4def026f3504199ded21f43ff38ff7b08881dcaf4a4fa635

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headson-0.2.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 749f5d012e6a1f8568b8ab610f523311f9d0ada92022f3e92ae3da8097c06abe
MD5 bc92a1e9f76630c23118b9a2dad4e52c
BLAKE2b-256 49787e3d8b3a3b7802250035561f7d26682bc9d4456bf36fee0a4f7be9d07291

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