/usr/bin/jo: invalid option -- '-'
Usage: jo [-a] [-B] [-D] [-d keydelim] [-p] [-e] [-n] [-o outfile] [-v] [-V] [-f file] [--] [-s|-n|-b] [word...]
word is key=value or key@value
-a creates an array of words
-B disable boolean true/false/null detection
-D deduplicate object keys
-d key will be object path separated by keydelim
-f load file as JSON object or array
-p pretty-prints JSON on output
-e quit if stdin is empty do not wait for input
-s coerce type guessing to string
-b coerce type guessing to bool
-n coerce type guessing to number
-o output to the given file
-v show version
-V show version in JSON
Options (8)
| Option | Description | Source |
|---|
-a | Interpret the list of words as array values and produce an array instead of an object. | man |
-B | By default, jo interprets the strings “true” and “false” as boolean elements true and false respectively, and “null” as null. | man |
-D | Deduplicate object keys. | man |
-e | Ignore empty stdin (i.e. don’t produce a diagnostic error when stdin is empty) | man |
-n | Do not add keys with empty values. | man |
-p | Pretty-print the JSON string on output instead of the terse one-line output it prints by default. | man |
-v | Show version and exit. | man |
-V | Show version as a JSON object and exit. | man |
Examples (27) from the manual page, untested
jo tst=1457081292 lat=12.3456 cc=FR badfloat=3.14159.26 name="JP Mens" nada= coffee@T
Create an object.jo -p -a *
Pretty-print an array with a list of files in the current directory:jo -p name=JP object=$(jo fruit=Orange hungry@0 point=$(jo x=10 y=20 list=$(jo -a 1 2 3 4 5)) number=17) sunday@0
Create objects within objects;jo switch=true morning@0
Booleans as strings or as boolean (pay particular attention to switch;jo -B switch=true morning@0
Booleans as strings or as boolean (pay particular attention to switch;jo -p name=Jane point[]=1 point[]=2 geo[lat]=10 geo[lon]=20
Elements (objects and arrays) can be nested.jo -p -d. name=Jane point[]=1 point[]=2 geo.lat=10 geo.lon=20
The same example, using object paths:jo -p name=Jane point[]=1 point[]=2 geo.lat=10 geo.lon=20
Without -d, a different object is generated:jo < /dev/null
Create empty objects or arrays, intentionally or potentially:MY_ARRAY=(a=1 b=2)
Create empty objects or arrays, intentionally or potentially:jo -a "${MY_ARRAY[@]}" < /dev/null
Create empty objects or arrays, intentionally or potentially:jo -p -- -s a=true b=true -s c=123 d=123 -b e="1" -b f="true" -n g="This is a test" -b h="This is a test"
Type coercion:jo -a -- -s 123 -n "This is a test" -b C_Rocks 456
Type coercion:jo program=jo authors=@AUTHORS
Read element values from files: a value which starts with @ is read in plain whereas if it begins with a % it will be base64-encoded and if it starts with : the contents are interpreted as JSON:jo filename=AUTHORS content=%AUTHORS
Read element values from files: a value which starts with @ is read in plain whereas if it begins with a % it will be base64-encoded and if it starts with : the contents are interpreted as JSON:jo nested=:nested.json
Read element values from files: a value which starts with @ is read in plain whereas if it begins with a % it will be base64-encoded and if it starts with : the contents are interpreted as JSON:jo name="JP Mens" twitter='\@jpmens'
These characters can be escaped to avoid interpretation:jo char=" " URIescape=\\%20
These characters can be escaped to avoid interpretation:jo action="split window" vimcmd="\:split"
These characters can be escaped to avoid interpretation:ls | jo -a > child.json
Read element values from a file in order to overcome ARG_MAX limits during object assignment:jo files:=child.json
Read element values from a file in order to overcome ARG_MAX limits during object assignment:ls *.c | jo -a > source.json; ls *.h | jo -a > headers.json
Read element values from a file in order to overcome ARG_MAX limits during object assignment:jo -a :source.json :headers.json
Read element values from a file in order to overcome ARG_MAX limits during object assignment:jo -f source.json 1 | jo -f - 2 3
Add elements to existing JSON:curl -s 'https://noembed.com/embed?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ' | jo -f - status=Rickrolled
Add elements to existing JSON:jo a=1 b=2 a=3
Deduplicate object keys (jo appends duplicate object keys by default):jo -D a=1 b=2 a=3
Deduplicate object keys (jo appends duplicate object keys by default):
Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.