Skip to content

Json

Index

json::sort

Sort JSON keys recursively. Reads from stdin or a file argument. Output: stdout — JSON with all object keys sorted

Arguments

  • $1 (JSON): file path (optional; reads stdin if omitted)

json::key_paths

List leaf key paths (paths to scalar values) in a JSON document, dotted with [N] for array indices, deduped and sorted. Reads from stdin or a file argument. Notes: jq's paths(scalars) keeps a leaf only when its value is truthy, so JSON null and false leaves are omitted (true, numbers including 0, and strings including "" are listed); array indices sort lexicographically ([10] before [2]); dotted output is ambiguous for keys that themselves contain "." or "[". Output: stdout — one key path per line, e.g. ".a.b", ".list[0].x"

Arguments

  • $1 (JSON): file path (optional; reads stdin if omitted)