node package manager

Introducing npm Enterprise add-ons. Integrate third-party dev tools into npm…


A cli program for running JSONPath queries. Wrapper of s3u/JSONPath


A cli program wrapping JSONPath

npm install JSONPathCLI -g

Accepts a jsonpath query as a parameter, and an optional filename to operate on

jsonpath $..* albums.json

If no file is provided it acts on stdin

cat albums.json | jsonpath $..*

Use the -c option to display a jsonpath cheatsheet

jsonpath -c

If the results are of a primitive type (string, number, boolean), they are output separated by a newline.

$ jsonpath $ sample.json 
Nigel Rees
Evelyn Waugh
Herman Melville
J. R. R. Tolkien

$ jsonpath $..price sample.json 

If the results are javascript objects, or if the -j option is used to force json output, then the results are output as colorised json (using util.inspect)

$ jsonpath $ sample.json -j
[ 'Nigel Rees',
  'Evelyn Waugh',
  'Herman Melville',
  'J. R. R. Tolkien' ]

$ jsonpath $[2:] sample.json 
[ { category: 'fiction',
    author: 'Herman Melville',
    title: 'Moby Dick',
    isbn: '0-553-21311-3',
    price: 8.99 },
  { category: 'fiction',
    author: 'J. R. R. Tolkien',
    title: 'The Lord of the Rings',
    isbn: '0-395-19395-8',
    price: 22.99 } ]