nq — a tiny, dependency-light JSON query tool for the command line.
Think "jq, but small": read JSON from stdin (or a file), apply a jq-lite filter, and print the result pretty (default), compact, or raw. It is the kind of thing every developer reaches for daily, which is exactly why it belongs in the NURL registry rather than the core stdlib — it stitches the ecosystem together: the argz registry package parses its flags, and the shipped stdlib/ext/json does the parsing/printing.
nq pretty-print stdin nq .user.name navigate into an object/array (.0 = index 0) nq '.items[]' iterate an array/object, one result per line nq '.items[].id' project a field out of each element nq '. | keys' object keys (or array indices) nq '. | length' length of an array / object / string nq -c . compact single-line output nq -r .user.name raw string output (no surrounding quotes) nq -f data.json . read from a file instead of stdin
Filter grammar (v0.1), deliberately tiny:
filter := path [ '|' func ] path := '.' | '.' seg ( ('.' | '[' int ']') seg )* [ '[]' [ '.' seg … ] ] func := 'keys' | 'length'
A single trailing [] turns the result into a stream: the preceding path must select an array or object, and the rest of the path is then applied to each element, one line of output per element.
@ main → i