jq Compatibility
aq aims to behave like jq 1.8 for jq programs. It doesn't promise 100% compatibility; this page says where it stands and how that is measured.
Signals
| Signal | Source | Gate | Current |
|---|---|---|---|
| Curated subset | tests/fixtures/jq_compat_suite.json | Required: CI fails below 100% | 216 / 216 |
| Harvested success cases | jq upstream test files | Report only | 908 / 908 |
Harvested %%FAIL cases | jq upstream test files | Report only | 19 / 19 |
The harvested numbers come from jq's master test files, which keep gaining cases, so the denominator moves. Rerun the scripts for current numbers:
python3 scripts/jq_compat_report.py # curated subset, runs the cargo test
python3 scripts/jq_upstream_report.py # harvested success cases
python3 scripts/jq_upstream_fail_report.py # harvested %%FAIL casesThe two upstream reporters need network access to fetch jq's test files and a built binary inside the repository (target/debug/aq by default, or --binary). CI runs all three and uploads the reports as artifacts.
Sources harvested: base64.test, jq.test, man.test, manonig.test, onig.test, optional.test, and uri.test from jqlang/jq. The curated subset draws from the same files except the two oniguruma regex files.
Drop-in use
aq accepts jq's command line: every jq 1.8 builtin, and the flags -n, -r, -j, -a, -s, -c, -C, -M, -S, -e, -f, -L, --tab, --indent, --stream, --seq, --arg, --argjson, --slurpfile, --rawfile, --args, --jsonargs, --raw-output0, and --unbuffered. A program may start with -, as in aq -n '-1 * 2'. Everything aq adds (other formats, -o, -p, -i, --line-stream, Starlark) is opt-in.
Known differences
- Regex engine.
aquses fancy-regex rather than Oniguruma. Look-around, backreferences, thel(longest match) flag, and$matching before a final newline work as in jq.\X(grapheme cluster) is not supported. - Recursion depth. As in jq, a call in tail position (nothing in the function runs after it) reuses the caller's frame, so tail recursion has no depth limit. Other recursion is limited to about 80,000 levels and reported as an error rather than crashing.
- jq master features. Where jq 1.8 and master differ,
aqfollows master, since that is what the upstream tests check:fromdateandfromdateiso8601accept the full ISO 8601 grammar (week and ordinal dates, fractions, offsets, dates before 1970), andrangereports "Range bounds and step must be numeric". - Math. The special functions (
tgamma,j0,y0,jn,yn, and so on) come from a port of musl's libm. They can differ from a glibc-linked jq in the last digit; a musl-linked jq prints the same digits asaq. input_line_numberalways returns0.--streambuilds each input before emitting its events, so it does not reduce memory for one huge document the way jq's incremental parser does.- Error text. Runtime errors print without jq's
jq: error (at FILE:LINE):prefix. As in jq, an error on one input is reported and the next input still runs, and exit codes match jq. Core error messages match for the upstream%%FAILcases, but stderr is not byte-for-byte identical in general.
Formats
The jq language runs the same way over every input format. Format-specific behavior (CSV rows as arrays of strings, TOML needing a single object, YAML scalar keys becoming strings) is described in the CLI reference.