Documentation
¶
Overview ¶
Command oj allows to filter JSON files.
usage: main [<options>] [@<extraction>]... [(<match>)]... [<json-file>]...
The default bahavior it to write the JSON formatted according to the color options and the indentation option. If no files are specified JSON input is expected from stdin.
Filtering and extraction of elements is supported using JSONPath and the scripting that is part of JSONPath filters.
Extraction paths can be provided either with the -x option or an argument starting with a $ or @. A Expr.Get() is executed and all the results are either written or wrapped with an array and written depending on the value of the wrap option (-w).
oj -x abc.def myfile.json "@.x[?(@.y > 1)]"
To filter JSON documents the match option (-m) is used. If a JSON document matches at least one match option the JSON will be written. In addition to the -m option an argument starting with a '(' is assumed to be a match script that follows the oj.Script format.
oj -m "(@.name == 'Pete')" myfile.json "(@.name == "Makie")"
An argument that starts with a { or [ marks the start of a JSON document that is composed of the remaining argument concatenated together.
-b bright color -c color -i int indent (default 2) -m value match equation/script -s sort -sen outpit in Simple Encoding Notation -w wrap extracts in an array -x value extract path -z lazy mode accepts Simple Encoding Notation (quotes and commas mostly optional)
Package main is the main package. (stupid comment to satisfy the linter).