Documentation ¶
Overview ¶
Command jqsh provides an interactive wrapper to the jq command line utility.
The filter stack ¶
The core concept in jqsh is a stack of jq "filters". Filters create a larger filter when joined with pipes "|". And maintaining a stack of filters allows exploritory querying of JSON structures.
Filters can be pushed onto the filter stack with ":push" and popped with ":pop".
> :push .[] > :push .type > :pop > :push [.type,.name] > :pop 2
The corresponding jq filter at each step is
.[] .[] | .type .[] .[] | [.type,.name] .
Notice that in the last step the stack was emptied with ":pop 2". But jqsh leaves a "." on the stack.
Read more about jq filters at the tool's online manual.
http://stedolan.github.io/jq/manual/#Basicfilters
Shell syntax ¶
The current shell syntax is rudimentory but it suffices. Lines prefixed with a colon ':' are commands, other lines are shorthand for specific commands. Following is a list of all shell syntax in jqsh.
:<cmd> <arg1> <arg2> ... execute cmd with the given arguments :<cmd> ... +<argN> execute cmd with an argument containing spaces (argN) . shorthand for ":write" .. shorthand for ":pop" ?<filter> shorthand for ":peek +<filter>" <filter> shorthand for ":push +<filter>"
Note that "." is a valid jq filter but pushing it on the filter stack lacks semantic value. So "." alone on a line is used as a shorthand for ":write".
Command reference ¶
A list of commands and other interactive help topics can be found through the "help" command.
> :help
Individual commands respond to the "-h" flag for usage documentation.