Manipulate data with ES6, Lodash or fromfrom, on command line.
Command line version of JSONNI
npm install -g jsonni-cli
- Reads data from
stdin
- Supports different syntaxes for querying data
- ES
- Lodash
- fromfrom
- Supports multiple output formats
- JSON
- CSV
- TSV
- Customizable output indentation
- Optionally minimized output JSON
Usage: jsonni [options]
Options:
-v, --version output the version number
-m --minify minify output
-q --query <query> query to transform data with
--input <format> input format. Available formats: json, tsv, csv
--input-header <header> input CSV/TSV headers. Separated with ","
--input-delimiter <delimiter> CSV/TSV input delimiter character. Defaults to ","
--output <format> output format. Available formats: json, tsv, csv
--output-delimiter <delimiter> CSV/TSV output delimiter character. Defaults to ","
--indent <indent> output indentation, defaults to " "
-h, --help output usage information
Parameter value should be quoted with single quotes ('
) instead of double ("
).
curl --silent http://jsonplaceholder.typicode.com/todos?_limit=5 | jsonni
curl --silent http://jsonplaceholder.typicode.com/todos?_limit=5 | jsonni -q '$input[0]'
curl --silent http://jsonplaceholder.typicode.com/todos?_limit=5 | jsonni -q '$input.filter(item => item.completed)'
curl --silent http://jsonplaceholder.typicode.com/todos?_limit=5 | jsonni -q '_.chain($input).orderBy(["title"], ["asc"]).map("title")'
curl --silent http://jsonplaceholder.typicode.com/todos?_limit=5 | jsonni -q '_.map(_.orderBy($input, ["title"], ["asc"]), "title")'
curl --silent http://jsonplaceholder.typicode.com/todos?_limit=5 | jsonni -q 'from($input).filter(item => item.title.startsWith("fugiat")).toArray()'
curl --silent http://jsonplaceholder.typicode.com/todos?_limit=5 | jsonni -q '$input[0]' --indent="\t"
curl --silent http://jsonplaceholder.typicode.com/todos?_limit=5 | jsonni -q '$input[0]' --output=csv --output-delimiter=";"
curl --silent http://jsonplaceholder.typicode.com/todos?_limit=5 | jsonni -q '$input[0]' --output=tsv
cat csv.csv | jsonni -q '$input[0]' --input=csv
cat csv.csv | jsonni -q '$input.filter(user => user.isActive)' --input=csv --output=csv
cat csv.csv | jsonni -q '$input.filter(user => user.isActive)' --input=csv --output=tsv
cat csvWithoutHeaders.csv | jsonni -q '$input[0]' --input=csv --input-header=id,isActive,age,name,registered
This project is a grateful recipient of the Futurice Open Source sponsorship program.
Icon made by Freepik from www.flaticon.com
MIT