-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
448839d
commit 27905e7
Showing
5 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
/docs/.cache | ||
/docs/venv | ||
/docs/site | ||
/docs/docs | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Welcome to rjq | ||
|
||
`rjq` is a simple and lightweight CLI JSON filtering tool designed for Windows and Linux. | ||
|
||
## Flags | ||
|
||
- `--load` - Loads JSON data from file. | ||
- `--query` - Query to be performed on the dataset. | ||
- `--params` - Selects specific fields that will be returned as result. | ||
|
||
## Commands | ||
|
||
* `rjq --load="<file name>"` - Loads JSON data from file and returns all the data as result. | ||
* `rjq --query="<query string>"` - Sets query string. | ||
* `rjq --params="<comma separated field names>"` - Sets fileds for the result | ||
|
||
## Usage | ||
|
||
* `rjq --load="test.json" --query="<query string>" --params="<comma separated field names>"` - Loads data from file, applies the query, returns array of objects with fields specified by '--params' flag. | ||
* `stto --json cpython | rjq --query="<query string>" --params="<comma separated field names>"` - Piping output from other program. | ||
|
||
***N.B.** [stto](https://github.com/mainak55512/stto) is a line of code counter used as an example here.* | ||
|
||
## Query structure | ||
|
||
Query is set by `--query` flag, e.g. `--query="age > 30 && percentage >= 50.0"`. | ||
rjq has a simple query structure, it follows `[field_name] [operator] [Value]` pattern. | ||
|
||
- `field_name` - It is the field name from the supplied dataset. For nested objects '.' operator should be used for accessing values, e.g. | ||
to access 'town' value from the following json: | ||
|
||
``` | ||
{ | ||
"_id": "88L33FM4VQBB1QYH", | ||
"address": { | ||
"postode": "CR45 9NE", | ||
"street": "3137 Stich Avenue", | ||
"town": "Swanley" | ||
} | ||
} | ||
``` | ||
use `address.town` in the field_name of the query. | ||
***N.B.** `field_name` should not be wrapped in any quotes.* | ||
- `Operator` - The following operators are supported for now: | ||
* `=` - `equal_to` operator, checks if both sides are same. | ||
* `!=` - `not_equals` operator, checks if both sides are NOT same. | ||
* `>` - `greather_than` operator, checks if `left` is greater than to `right`. | ||
* `<` - `less_than` operator, checks if `left` is lesser than to `right`. | ||
* `>=` - `greather_than_or_equal` operator, checks if `left` is greater than to `right` or same. | ||
* `<=` - `less_than_or_equal` operator, checks if `left` is lesser than to `right` or same. | ||
* `&&` - `and` operator, joins two Binary expressions, e.g. `age > 18 && percentage < 34.0`. | ||
* `||` - `or` operator, joins two Binary expressions, e.g. `age > 18 || percentage < 34.0`. | ||
- `Value` - rjq supports 3 types of values, `string`, `boolean` & `number`. | ||
* `String` - strings should be wrapped in single quotes (') only, e.g. `'name'`, `'address'` etc. | ||
* `Boolean` - `true`/`false` without any quotes. | ||
* `Number` - Any number without quotes. For comparing decimal numbers decimal point should be provided, e.g. for quering `age` & `percentage` of the following - | ||
``` | ||
{ | ||
"age": 30, | ||
... | ||
"percentage": 56.34, | ||
... | ||
} | ||
``` | ||
use something like `age > 18 && percentage > 50.0`. | ||
## Parameters | ||
Output parameters are set by `--params` flag e.g. `--params="name, address.town"`. | ||
Dot walking is supported for nested object fields. | ||
## Project layout | ||
src/ | ||
main.rs # Entry point for the program. | ||
lexer.rs # Lexer of the program, tokenizes the query string. | ||
parser.rs # Parser of the program, creates Abstract syntax tree from the tokens generated by the lexer. | ||
interpreter.rs # Interprets the AST and returns boolean value after evaluating the query. | ||
helper.rs # Utility file. | ||
Cargo.toml # Configuration file for the project. | ||
LICENSE # License file. | ||
README.md # Readme file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Welcome to rjq","text":""},{"location":"#flags","title":"Flags","text":"<ul> <li><code>--load</code> - Loads JSON data from file.</li> <li><code>--query</code> - Query to be performed on the dataset.</li> <li><code>--params</code> - Selects specific fields that will be returned as result.</li> </ul>"},{"location":"#commands","title":"Commands","text":"<ul> <li><code>rjq --load=\"<file name>\"</code> - Loads JSON data from file and returns all the data as result.</li> <li><code>rjq --query=\"<query string>\"</code> - Sets query string.</li> <li><code>rjq --params=\"<comma separated field names>\"</code> - Sets fileds for the result</li> </ul>"},{"location":"#usage","title":"Usage","text":"<ul> <li><code>rjq --load=\"test.json\" --query=\"<query string>\" --params=\"<comma separated field names>\"</code> - Loads data from file, applies the query, returns array of objects with fields specified by '--params' flag.</li> <li> <p><code>stto --json cpython | rjq --query=\"<query string>\" --params=\"<comma separated field names>\"</code> - Piping output from other program.</p> <p>N.B. stto is a line of code counter used as an example here.</p> </li> </ul>"},{"location":"#query-structure","title":"Query structure","text":"<p>Query is set by <code>--query</code> flag, e.g. <code>--query=\"age > 30 && percentage >= 50.0\"</code>. rjq has a simple query structure, it follows <code>[field_name] [operator] [Value]</code> pattern.</p> <ul> <li> <p><code>field_name</code> - It is the field name from the supplied dataset. For nested objects '.' operator should be used for accessing values, e.g. to access 'town' value from the following json:</p> <p><code>{ \"_id\": \"88L33FM4VQBB1QYH\", \"address\": { \"postode\": \"CR45 9NE\", \"street\": \"3137 Stich Avenue\", \"town\": \"Swanley\" } }</code></p> <p>use <code>address.town</code> in the field_name of the query.</p> <p>N.B. <code>field_name</code> should not be wrapped in any quotes.</p> </li> <li> <p><code>Operator</code> - The following operators are supported for now:</p> <ul> <li><code>=</code> - <code>equal_to</code> operator, checks if both sides are same.</li> <li><code>!=</code> - <code>not_equals</code> operator, checks if both sides are NOT same.</li> <li><code>></code> - <code>greather_than</code> operator, checks if <code>left</code> is greater than to <code>right</code>.</li> <li><code><</code> - <code>less_than</code> operator, checks if <code>left</code> is lesser than to <code>right</code>.</li> <li><code>>=</code> - <code>greather_than_or_equal</code> operator, checks if <code>left</code> is greater than to <code>right</code> or same.</li> <li><code><=</code> - <code>less_than_or_equal</code> operator, checks if <code>left</code> is lesser than to <code>right</code> or same.</li> <li><code>&&</code> - <code>and</code> operator, joins two Binary expressions, e.g. <code>age > 18 && percentage < 34.0</code>.</li> <li><code>||</code> - <code>or</code> operator, joins two Binary expressions, e.g. <code>age > 18 || percentage < 34.0</code>.</li> </ul> </li> <li><code>Value</code> - rjq supports 3 types of values, <code>string</code>, <code>boolean</code> & <code>number</code>.<ul> <li><code>String</code> - strings should be wrapped in single quotes (') only, e.g. <code>'name'</code>, <code>'address'</code> etc.</li> <li><code>Boolean</code> - <code>true</code>/<code>false</code> without any quotes.</li> <li><code>Number</code> - Any number without quotes. For comparing decimal numbers decimal point should be provided, e.g. for quering <code>age</code> & <code>percentage</code> of the following - <code>{ \"age\": 30, ... \"percentage\": 56.34, ... }</code> use something like <code>age > 18 && percentage > 50.0</code>.</li> </ul> </li> </ul>"},{"location":"#parameters","title":"Parameters","text":"<p>Output parameters are set by <code>--params</code> flag e.g. <code>--params=\"name, address.town\"</code>. Dot walking is supported for nested object fields.</p>"},{"location":"#project-layout","title":"Project layout","text":"<pre><code>src/\n main.rs # Entry point for the program.\n lexer.rs # Lexer of the program, tokenizes the query string.\n parser.rs # Parser of the program, creates Abstract syntax tree from the tokens generated by the lexer.\n interpreter.rs # Interprets the AST and returns boolean value after evaluating the query.\n helper.rs # Utility file.\n\nCargo.toml # Configuration file for the project.\n\nLICENSE # License file.\n\nREADME.md # Readme file.\n</code></pre>"}]} | ||
{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Welcome to rjq","text":"<p><code>rjq</code> is a simple and lightweight CLI JSON filtering tool designed for Windows and Linux.</p>"},{"location":"#flags","title":"Flags","text":"<ul> <li><code>--load</code> - Loads JSON data from file.</li> <li><code>--query</code> - Query to be performed on the dataset.</li> <li><code>--params</code> - Selects specific fields that will be returned as result.</li> </ul>"},{"location":"#commands","title":"Commands","text":"<ul> <li><code>rjq --load=\"<file name>\"</code> - Loads JSON data from file and returns all the data as result.</li> <li><code>rjq --query=\"<query string>\"</code> - Sets query string.</li> <li><code>rjq --params=\"<comma separated field names>\"</code> - Sets fileds for the result</li> </ul>"},{"location":"#usage","title":"Usage","text":"<ul> <li><code>rjq --load=\"test.json\" --query=\"<query string>\" --params=\"<comma separated field names>\"</code> - Loads data from file, applies the query, returns array of objects with fields specified by '--params' flag.</li> <li> <p><code>stto --json cpython | rjq --query=\"<query string>\" --params=\"<comma separated field names>\"</code> - Piping output from other program.</p> <p>N.B. stto is a line of code counter used as an example here.</p> </li> </ul>"},{"location":"#query-structure","title":"Query structure","text":"<p>Query is set by <code>--query</code> flag, e.g. <code>--query=\"age > 30 && percentage >= 50.0\"</code>. rjq has a simple query structure, it follows <code>[field_name] [operator] [Value]</code> pattern.</p> <ul> <li> <p><code>field_name</code> - It is the field name from the supplied dataset. For nested objects '.' operator should be used for accessing values, e.g. to access 'town' value from the following json:</p> <p><code>{ \"_id\": \"88L33FM4VQBB1QYH\", \"address\": { \"postode\": \"CR45 9NE\", \"street\": \"3137 Stich Avenue\", \"town\": \"Swanley\" } }</code></p> <p>use <code>address.town</code> in the field_name of the query.</p> <p>N.B. <code>field_name</code> should not be wrapped in any quotes.</p> </li> <li> <p><code>Operator</code> - The following operators are supported for now:</p> <ul> <li><code>=</code> - <code>equal_to</code> operator, checks if both sides are same.</li> <li><code>!=</code> - <code>not_equals</code> operator, checks if both sides are NOT same.</li> <li><code>></code> - <code>greather_than</code> operator, checks if <code>left</code> is greater than to <code>right</code>.</li> <li><code><</code> - <code>less_than</code> operator, checks if <code>left</code> is lesser than to <code>right</code>.</li> <li><code>>=</code> - <code>greather_than_or_equal</code> operator, checks if <code>left</code> is greater than to <code>right</code> or same.</li> <li><code><=</code> - <code>less_than_or_equal</code> operator, checks if <code>left</code> is lesser than to <code>right</code> or same.</li> <li><code>&&</code> - <code>and</code> operator, joins two Binary expressions, e.g. <code>age > 18 && percentage < 34.0</code>.</li> <li><code>||</code> - <code>or</code> operator, joins two Binary expressions, e.g. <code>age > 18 || percentage < 34.0</code>.</li> </ul> </li> <li><code>Value</code> - rjq supports 3 types of values, <code>string</code>, <code>boolean</code> & <code>number</code>.<ul> <li><code>String</code> - strings should be wrapped in single quotes (') only, e.g. <code>'name'</code>, <code>'address'</code> etc.</li> <li><code>Boolean</code> - <code>true</code>/<code>false</code> without any quotes.</li> <li><code>Number</code> - Any number without quotes. For comparing decimal numbers decimal point should be provided, e.g. for quering <code>age</code> & <code>percentage</code> of the following - <code>{ \"age\": 30, ... \"percentage\": 56.34, ... }</code> use something like <code>age > 18 && percentage > 50.0</code>.</li> </ul> </li> </ul>"},{"location":"#parameters","title":"Parameters","text":"<p>Output parameters are set by <code>--params</code> flag e.g. <code>--params=\"name, address.town\"</code>. Dot walking is supported for nested object fields.</p>"},{"location":"#project-layout","title":"Project layout","text":"<pre><code>src/\n main.rs # Entry point for the program.\n lexer.rs # Lexer of the program, tokenizes the query string.\n parser.rs # Parser of the program, creates Abstract syntax tree from the tokens generated by the lexer.\n interpreter.rs # Interprets the AST and returns boolean value after evaluating the query.\n helper.rs # Utility file.\n\nCargo.toml # Configuration file for the project.\n\nLICENSE # License file.\n\nREADME.md # Readme file.\n</code></pre>"}]} |