Options

Help

Boolean

Used as --help

Prints the help message will all the options available for use, description about each positional argument from the command, examples and more:

jstr --help

Input

Boolean

Used as --input or -i

Reads a JSON input from the stdin (a piped command, for example) rather than from a file path:

cat my-file.json | jstr -i

The command above is equivalent to:

jstr my-file.json

This option is quite useful if your JSON output comes from another command/script.

Copy

Boolean

Used as --copy or -c

Copies the output to your clipboard rather than printing it:

One of the original needs for a tool like this was to use it on env. variables that were a stringified JSON, this option is quite useful for that.

CSV

Boolean

Used as --csv

Formats the output to CSV:

Or if you want the output saved to a file:

Keep in mind if you pass the JavaScript callback function to parse your output, the data returned by your callback has to be at least an Object or an Array of objects.

Otherwise you'll receive an error, since other data structures can't be formatted to CSV.

Clipboard

Boolean

Used as --clipboard

Reads a JSON input from the clipboard:

Map

String

Used as --map or -m

Accepts a JSON to use as a map for field -> alias transformation:

The example above will simply rename myKey to myNewKey.

Omit

String

Used as --omit or -o

Omits/removes comma separated fields from the output:

Prefix

String

Used as --prefix

Adds a prefix to every key of the object passed as input.

If the object is an array of objects, it will add the prefix to every object in it:

Suffix

String

Used as --suffix

Adds a suffix to every key of the object passed as input.

If the object is an array of objects, it will add the suffix to every object in it:

Spaces

Number

Used as --spaces or -s

Adds spaces to the output.

The number provided equals the number of spaces added in the indentation:

Last updated