Skip to content

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 ​

SignalSourceGateCurrent
Curated subsettests/fixtures/jq_compat_suite.jsonRequired: CI fails below 100%216 / 216
Harvested success casesjq upstream test filesReport only908 / 908
Harvested %%FAIL casesjq upstream test filesReport only19 / 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:

bash
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 cases

The 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. aq uses fancy-regex rather than Oniguruma. Look-around, backreferences, the l (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, aq follows master, since that is what the upstream tests check: fromdate and fromdateiso8601 accept the full ISO 8601 grammar (week and ordinal dates, fractions, offsets, dates before 1970), and range reports "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 as aq.
  • input_line_number always returns 0.
  • --stream builds 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 %%FAIL cases, 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.

Structured querying, rewriting, and Starlark scripting across common data formats.