Giter Site home page Giter Site logo

jp's Introduction

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

jp's People

Contributors

spiralx avatar therealklanni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jp's Issues

Syntax error

@therealklanni
Hi, thanks for this package.

I tried to run version v2.0.1 and v2.0.0 and get the following error:

/usr/bin/jp: line 1: syntax error near unexpected token `('
/usr/bin/jp: line 1: `const _ = require(`lodash`)'

I think the problem is that

#!/usr/bin/env node

is missing at the beginning of the index.js file. Would have submitted a PR but I don' know how you would like to proceed beause I saw that in older versions you kept different files for the commandline file and the index.js file.

My node version is 6.10.3.
My npm version is 3.10.10.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.