File: jgrep.man.1.rst

package info (click to toggle)
jgrep 1.5.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 184 kB
  • sloc: ruby: 1,004; makefile: 8
file content (117 lines) | stat: -rw-r--r-- 2,726 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
=====
jgrep
=====

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

:Author: Gabriel Filion
:Date: 2020
:Manual section: 1

Synopsis
========

| jgrep <expression> [options]

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.

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

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) and expression2`
|     Performs the operations inside the perentheses first.

Statements
==========

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

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

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