JGREP(1)

πŸ“¦
version 1.5.4 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– JGREP(1) β€” the jgrep manual, but make it cute πŸ’–

okay bestie, sit down, hydrate, and let me tell you about jgrep β€” a command line tool and API for parsing JSON documents based on logical expressions. she's giving filter queen, she's giving query energy, and honestly? she ate. πŸ“


✨ SYNOPSIS ✨

jgrep <expression> [options]

like that's it. that's the whole vibe. you hand her an expression, she hands you truth. 🫢


🌸 DESCRIPTION 🌸

so here's the tea: jgrep can be used for filtering the contents of a JSON (JavaScript Object Notation) file after having parsed it. no cap. πŸ”₯

and the expressions? they're doing the most, in the best way:

  • they can help with testing for the presence or absence of certain elements in the file πŸ’…
  • they can also test the values of certain elements ⭐

it's giving "I don't read the whole JSON, I interrogate it". main character behavior fr fr.


πŸ‘‘ OPTIONS πŸ‘‘

every single flag, exactly as she is. no skipping, no summarizing, we respect the craft. πŸ’œ

  • -s, --simple <FIELD...> β€” greps the JSON and only returns the value of the field(s) specified. just the value, nothing extra, minimalism slay ✨
  • -c, --compat β€” returns the JSON in its non-pretty flat form. compact. efficient. lowkey iconic πŸŽ€
  • -n, --stream β€” specify continuous input. she keeps listening, she's patient like that πŸ¦‹
  • -f, --flatten β€” flatten the results as much as possible. squish. 🫢
  • -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. iykyk πŸ“₯
  • -q, --quiet β€” quiet; don't write to stdout. Exit with zero status if match found. she says nothing and still wins πŸ’€
  • -v, --verbose β€” verbose output that will list a document if it fails to parse. she's gonna tell you exactly which doc fumbled πŸ™ˆ
  • --start <FIELD> β€” starts the grep at a specific key in the document. skip to the good part 🌈
  • --slice <RANGE> β€” a range of the form 'n' or 'n..m', indicating which documents to extract from the final output. portion control bestie πŸ“

🧚 EXPRESSIONS 🧚

JGrep uses the following logical symbols to define expressions. memorize them, they're your new love language πŸ’–

and

[statement] and [statement]

Evaluates to true if both statements are true. both. BOTH. no half measures πŸ’…

or

[statement] and [statement]

Evaluates true if either statement is true. (yes, that's literally what the page says up there, we're keeping it verbatim, no editing the source material βœ‹)

not | !

! [statement]
not [statement]

Inverts the value of statement. flip it, reverse it, turn it upside down πŸ”„

+

+[value]

Returns true if value is present in the json document. presence check, she's here, she's accounted for ✨

-

-[value]

Returns true if value is not present in the json doument. absence check β€” if she's not in the building, that's a true 🚫

( and )

(expression1) and expression2

Performs the operations inside the perentheses first. parentheses are the VIP section, they go first, periodt πŸ‘‘


🌈 STATEMENTS 🌈

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

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

that's it, that's the toolbox, and honestly she does so much with so little πŸ’œ


⭐ EXAMPLES ⭐

Given the following JSON document:

{"foo":1, "bar":null}

the following are examples of valid expressions:

+foo

returns true βœ…

-bar

returns false ❌

+foo and !(foo=2)

returns true βœ…

!(foo>=2 and bar=null) or !(bar=null)

returns true βœ…

see how she's thinking? logical. precise. obsessed. 🧠✨


πŸŽ€ AUTHOR πŸŽ€

Gabriel Filion


and that's the whole page bestie, no crumbs left. this was the jgrep(1) manual, dated 2020 β€” go forth and filter your JSON with main character energy. bye love you, drink water πŸ’–πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from