-{"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>"}]}
0 commit comments