Skip to content

Latest commit

 

History

History
86 lines (65 loc) · 2.54 KB

README.md

File metadata and controls

86 lines (65 loc) · 2.54 KB

GitHub license Build Status npm Prettier

jp

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

Usage

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

Examples

$ 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

License

MIT © therealklanni