logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

jgrep - Command line tool and API for parsing JSON documents based on logical expressions

Author

       Gabriel Filion

                                                      2020                                              JGREP(1)

Description

       jgrep  can  be  used  for filtering the contents of a JSON (JavaScript Object Notation) file after having
       parsed it. The expressions can help testing for the presence or absence of certain elements in the  file.
       They can also test the values of certain elements.

Examples

       Given the following JSON document:
          {"foo":1,"bar":null}

       the following are examples of valid expressions:

       +foo
         returns true

       -bar
         returns false

       +fooand!(foo=2)
         returns true

       !(foo>=2andbar=null)or!(bar=null)
         returns true

Expressions

       JGrep uses the following logical symbols to define expressions.

       and[statement]and[statement]
         Evaluates to true if both statements are true

       or[statement]and[statement]
         Evaluates true if either statement is true

       not | !![statement]not[statement]
         Inverts the value of statement

       ++[value]
         Returns true if value is present in the json document

       --[value]
         Returns true if value is not present in the json doument

       ( and )(expression1)andexpression2
         Performs the operations inside the perentheses first.

Name

       jgrep - Command line tool and API for parsing JSON documents based on logical expressions

Options

-s | --simple <FIELD...>
         Greps the JSON and only returns the value of the field(s) specified

       -c | --compat
         Returns the JSON in its non-pretty flat form

       -n | --stream
         Specify continuous input

       -f | --flatten
         Flatten the results as much as possible

       -i | --input <FILENAME>
         Target JSON file to use as input. If this option is not specified, jgrep
         will expect to find JSON content on the standard input.

       -q | --quiet
         Quiet; don't write to stdout.  Exit with zero status if match found.

       -v | --verbose
         Verbose output that will list a document if it fails to parse

       --start <FIELD>
         Starts the grep at a specific key in the document

       --slice <RANGE>
         A range of the form 'n' or 'n..m', indicating which documents to extract
         from the final output

Statements

       A statement is defined as some value in a JSON document compared to another value.

       Available comparison operators are =, <, >, <= and >=

Synopsis

       jgrep <expression> [options]

See Also