jq — Built-in JSON Processor
Prowl ships a built-in jq command (via github.com/itchyny/gojq) available
in the bash tool. No external binary is required.
Supported Flags
| Flag |
Description |
-r, --raw-output |
Output strings without quotes |
-j, --join-output |
Like -r but no trailing newline |
-c, --compact-output |
One-line JSON output |
-s, --slurp |
Read all inputs into an array |
-n, --null-input |
Use null as input (ignore stdin) |
-e, --exit-status |
Exit 1 if last output is false or null |
-R, --raw-input |
Read each line as a string, not JSON |
--arg name value |
Bind $name to a string value |
--argjson name value |
Bind $name to a parsed JSON value |
File arguments after the filter are also supported: jq '.foo' file.json.
Differences from Standard jq
The built-in uses gojq, which is a pure-Go jq implementation. Key
differences:
- No object key ordering — keys are sorted by default;
keys_unsorted
and -S are unavailable.
- Arbitrary-precision integers — large integers keep full precision
(addition, subtraction, multiplication, modulo, division when divisible).
- String indexing —
"abcde"[2] returns "c".
- Not supported —
--ascii-output, --seq, --stream,
--stream-errors, -f/--from-file, --slurpfile, --rawfile,
--args, --jsonargs, input_line_number, $__loc__, some regex
features (backreferences, look-around).
- YAML — gojq supports
--yaml-input/--yaml-output but the
built-in does not currently expose these flags.
Common Patterns
Extract a field:
echo '{"name":"prowl"}' | jq '.name'
Filter an array:
echo '[1,2,3,4,5]' | jq '[.[] | select(. > 3)]'
Reshape objects:
echo '{"first":"Ada","last":"Lovelace"}' | jq '{full: (.first + " " + .last)}'
Use variables:
echo '{}' | jq --arg host localhost --argjson port 8080 '{host: $host, port: $port}'
Slurp multiple JSON values:
echo '{"a":1}{"b":2}' | jq -s '.'
Compact output for piping:
echo '{"a":1}' | jq -c '.a += 1'
Raw string output:
echo '["one","two","three"]' | jq -r '.[]'
Process a file:
jq '.dependencies | keys' package.json
Null input for constructing JSON:
jq -n --arg msg hello '{"message": $msg}'
Tips
- Pipe jq output to other commands:
jq -r '.url' data.json | xargs curl
- Chain filters with
| inside the expression, not shell pipes.
- Use
try to suppress errors on missing keys: jq 'try .foo.bar'
- Use
// "default" for fallback values: jq '.name // "unknown"'
- Use
@csv, @tsv, @base64, @html, @uri for format strings.
1---2name: jq3description: Use when the user needs to query, filter, reshape, extract, create, or construct JSON data — including API responses, config files, log output, or any structured data — or when helping the user write or debug JSON transformations.4---56# jq — Built-in JSON Processor78Prowl ships a built-in `jq` command (via `github.com/itchyny/gojq`) available9in the bash tool. No external binary is required.1011## Supported Flags1213| Flag | Description |14|------|-------------|15| `-r`, `--raw-output` | Output strings without quotes |16| `-j`, `--join-output` | Like `-r` but no trailing newline |17| `-c`, `--compact-output` | One-line JSON output |18| `-s`, `--slurp` | Read all inputs into an array |19| `-n`, `--null-input` | Use `null` as input (ignore stdin) |20| `-e`, `--exit-status` | Exit 1 if last output is `false` or `null` |21| `-R`, `--raw-input` | Read each line as a string, not JSON |22| `--arg name value` | Bind `$name` to a string value |23| `--argjson name value` | Bind `$name` to a parsed JSON value |2425File arguments after the filter are also supported: `jq '.foo' file.json`.2627## Differences from Standard jq2829The built-in uses gojq, which is a pure-Go jq implementation. Key30differences:3132- **No object key ordering** — keys are sorted by default; `keys_unsorted`33 and `-S` are unavailable.34- **Arbitrary-precision integers** — large integers keep full precision35 (addition, subtraction, multiplication, modulo, division when divisible).36- **String indexing** — `"abcde"[2]` returns `"c"`.37- **Not supported** — `--ascii-output`, `--seq`, `--stream`,38 `--stream-errors`, `-f`/`--from-file`, `--slurpfile`, `--rawfile`,39 `--args`, `--jsonargs`, `input_line_number`, `$__loc__`, some regex40 features (backreferences, look-around).41- **YAML** — gojq supports `--yaml-input`/`--yaml-output` but the42 built-in does not currently expose these flags.4344## Common Patterns4546Extract a field:47```sh48echo '{"name":"prowl"}' | jq '.name'49```5051Filter an array:52```sh53echo '[1,2,3,4,5]' | jq '[.[] | select(. > 3)]'54```5556Reshape objects:57```sh58echo '{"first":"Ada","last":"Lovelace"}' | jq '{full: (.first + " " + .last)}'59```6061Use variables:62```sh63echo '{}' | jq --arg host localhost --argjson port 8080 '{host: $host, port: $port}'64```6566Slurp multiple JSON values:67```sh68echo '{"a":1}{"b":2}' | jq -s '.'69```7071Compact output for piping:72```sh73echo '{"a":1}' | jq -c '.a += 1'74```7576Raw string output:77```sh78echo '["one","two","three"]' | jq -r '.[]'79```8081Process a file:82```sh83jq '.dependencies | keys' package.json84```8586Null input for constructing JSON:87```sh88jq -n --arg msg hello '{"message": $msg}'89```9091## Tips9293- Pipe jq output to other commands: `jq -r '.url' data.json | xargs curl`94- Chain filters with `|` inside the expression, not shell pipes.95- Use `try` to suppress errors on missing keys: `jq 'try .foo.bar'`96- Use `// "default"` for fallback values: `jq '.name // "unknown"'`97- Use `@csv`, `@tsv`, `@base64`, `@html`, `@uri` for format strings.