Repository navigation
sjq is a command-line JSON processor that reads the jq language, built on simdjson. Documentation: https://simdjson.github.io/sjq/
Install
Linux and macOS:
curl -fsSL https://raw.githubusercontent.com/simdjson/sjq/main/install.sh | sh
Windows (PowerShell):
irm https://raw.githubusercontent.com/simdjson/sjq/main/install.ps1 | iex
Homebrew (macOS and Linux):
brew install simdjson/tap/sjq
Scoop (Windows):
scoop bucket add sjq https://github.com/simdjson/sjq
scoop install sjq/sjq
Or download the archive for your system below: static Linux binaries (x86-64, ARM64), a universal macOS binary, and Windows x64 and ARM64 builds. SHA256SUMS has their checksums. To update: brew upgrade sjq, scoop update sjq, or run the install script again.
What is new
Faster on newline-delimited JSON. Files from 1 MB on are filtered by worker threads, in smaller pieces, and the threads wait less on each other. On a 64-core machine, filters that extract or build a few fields from 1 GB of NDJSON run 1.4x to 1.5x faster than with 0.2.0; sjq is now 139 to 184 times faster than jq 1.8.2 on these workloads (charts: https://simdjson.github.io/sjq/#performance).
Clearer errors.
- A filter that does not compile is shown with the line, the column and a caret under the problem, with hints: a likely typo (
lenght: did you meanlength?), a field name with accents written without quotes (.annéeneeds."année"), single quotes in Windowscmd. - Invalid JSON is described in plain words, with its line and column:
invalid JSON at line 3, column 3: expected a value but found ',' after ','. - A file that cannot be read says why (missing, a directory, permission denied).
Writing a file: -o FILE. sjq writes the output itself, in UTF-8. The file is replaced only at the end of a successful run, so it can also be the input (sjq -o data.json '.items' data.json), and a failed run leaves it unchanged. Symbolic links and permissions are kept.
Windows.
- UTF-16 input with a byte order mark (what Windows PowerShell 5 writes with
>, or whattypesends through a pipe) is read; UTF-16 without one is refused with an explanation. - A byte order mark at the start of a
-ffilter file is accepted. - The documentation explains how to quote filters in PowerShell and
cmd.
Other changes.
- Streams given by name are read:
sjq . <(curl -s ...), named pipes. - As with jq, invalid JSON input makes the exit status 5 even when later inputs are valid.
--fracturedwrites the compact yet readable FracturedJson layout (since 0.2.0).
Fixes.
- An object constructor with a duplicate key (
{a, a: .b}) could read freed memory. haltandhalt_errorcrashed on files larger than 64 MB.- MinGW builds could crash when a filter failed on a worker thread (the release binaries, built with MSVC, were not affected).
The fast path still validates only the parts of the input a filter reads: see "Invalid JSON" in the documentation.