Simply parse JSON from any input source.
Inspired by jq; not a replacement. Supports Lodash .get() path syntax and JSONPath syntax. Also supports stdin streaming (see last example), i.e. line-by-line.
yarn global add jp-cli || npm install -g jp-cli
Pipe jp onto a JSON source from the commandline to parse the output:
cat data.json | jp [options] query
Options:
-p, --path Use JSON Path notation (https://github.com/dchester/jsonpath)
-k, --keys Print object keys only [boolean]
-f, --file Read input from file [string]
-i, --indent Number of spaces for indentation (ignored by --human)
[number] [default: 2]
-h, --human Print human-readable (non-JSON) format [boolean]
-b, --break Set break length of object/array for human format [number]
-c, --no-color Disable color for human format [boolean]
-d, --depth Depth for human format [number]
-L, --line-by-line Parse each line as a separate input [boolean]
--help Show help [boolean]
Queries use the Lodash get method by default.
For more information, see https://github.com/therealklanni/jp
$ cat user-response.json | jp data.user
{
"name": "Gazorpazorpfield",
"color": "orange"
}
$ cat user-response.json | jp data.user | jp --keys
[
"name",
"color"
]
$ cat user-response.json | jp data.user.name
"Gazorpazorpfield"
jp
can also parse JSON line-by-line from a stdin stream.
$ ipfs log tail | jp -L event | jq -r
updatePeer
handleFindPeerBegin
handleFindPeer
updatePeer
handleFindPeerBegin
handleFindPeer
Bitswap.Rebroadcast.active
Bitswap.Rebroadcast.idle
... until you ^C
MIT © therealklanni