jp is a JSON processor for the command line using JSONPath (aka "a simpler jq, and with JSONPath").
$ echo '{"some": ["value", 3]}' | jp -r '$.some.*'
value
3
$ echo '{"some": ["value", 3]}' | jp
{
"some": [
"value",
3
]
}
jp uses jsonpath_lib under the hood. You can check its implementation of JSONPath here.
See Howto jp for an introduction.
# First, on GNU/Linux
$ curl -L -o jp https://github.com/cburgmer/jp/releases/download/0.4.0/jp-x86_64-unknown-linux-gnu
# or on OS X
$ curl -L -o jp https://github.com/cburgmer/jp/releases/download/0.4.0/jp-x86_64-apple-darwin
# and finally
$ chmod a+x jp && mv jp /usr/local/bin
$ jp --help
A simpler jq, and with JSONPath
Usage: jp [OPTIONS] [SELECTOR]...
Arguments:
[SELECTOR]... JSONPath selector(s)
Options:
-r Unwraps primitive JSON values
-t Transposes all matches per document, separated by tabs
-0 Separates all matches by NUL (\0), helpful in conjunction with xargs -0
--example Prints example JSON for practising JSONPath
-h, --help Print help information
-V, --version Print version information
SELECTOR EXAMPLES:
array index $[2]
object key $.key
complex object key $['a key']
union $['key','another']
array slice $[0:4]
filter expression $[?(@.key==42)]
recursive descent $..key
wildcard $.*
E.g. get the prices of everything in the store:
jp --example | jp '$.store..price'
jq is quite successful, but has a steep learning curve. jp wants to be simpler:
-
JSONPath is a standard (more or less) implemented in many languages (compare https://cburgmer.github.io/json-path-comparison/). jq ships with its very own idea of a query language. Let's focus on one query language we can reuse in other areas.
-
jq is powerful and complex. Unix on the other hand already solves some of the problems jq addresses. Let's not reinvent the wheel.
In absence of a roadmap here are a few queries from an actual shell history: goals/JQ_EXAMPLES.md
Also so far unanswered questions: goals/Questions.md