LinuxCommandLibrary

jo

TLDR

Create JSON object

$ jo name=[value] count:=[42]
copy
Create JSON array
$ jo -a [item1] [item2] [item3]
copy
Nested objects
$ jo name=[test] config=$(jo debug:=[true])
copy
Read from stdin
$ echo "[value]" | jo name=@-
copy
Read from file
$ jo content=@[file.txt]
copy
Pretty print
$ jo -p name=[value]
copy

SYNOPSIS

jo [options] [key=value...]

DESCRIPTION

jo creates JSON from shell arguments. It builds objects and arrays from command-line key-value pairs.
The tool enables JSON generation in shell scripts. Type hints distinguish strings from numbers and booleans.
jo generates JSON from shell.

PARAMETERS

KEY=VALUE

String value assignment.
KEY:=VALUE
Non-string value (number, boolean, null).
-a
Create array instead of object.
-p
Pretty print output.
@FILE
Read value from file.
@-
Read value from stdin.
--help
Display help information.

CAVEATS

Shell quoting important. Use := for non-strings. Nested structures via subshell.

HISTORY

jo was created by Jan-Piet Mens to simplify JSON creation in shell scripts without complex quoting.

SEE ALSO

jq(1), jc(1), gron(1)

Copied to clipboard