JO(1) JO(1) (NAME) jo - JSON (SYNOPSIS) jo [-p] [-a] [-B] [-D] [-e] [-n] [-v] [-V] [-d keydelim] [-f file] [-] [ [-s|-n|-b] word ...] (DESCRIPTION) jo word stdin JSON stdout . -f jo file JSON word JSON stdout . file - jo word stdin . -a word key=value ( key@value) key JSON value . jo value ( strtod(3)) null JSON . value null . -n . jo key (literal) . -d key (object path) keydelim . jo value : (value) (action) ------------------------------------------------------------ @file file %file file base64 :file file JSON (escape) . jo key@value (boolean) JSON : T t true false . -a jo . := word := JSON . - jo ..SH " (TYPE COERCION)" jo word -s string () -n number () -b boolean () . word -- jo . : word -s -n -b ---------------------------------------------------------------------------- a= "a":"" "a":0 "a":false "a":null a=string "a":"string" "a":6 "a":true "a":"string" a="quoted" "a":""quoted"" "a":8 "a":true "a":""quoted"" a=12345 "a":"12345" "a":12345 "a":true "a":12345 a=true "a":"true" "a":1 "a":true "a":true a=false "a":"false" "a":0 "a":false "a":false a=null "a":"" "a":0 "a":false "a":null . false true . word key=value word -a . word ..SH " (EXAMPLES)" . : $ jo tst=1457081292 lat=12.3456 cc=FR badfloat=3.14159.26 name="JP Mens" nada= coffee@T {"tst":1457081292,"lat":12.3456,"cc":"FR","badfloat":"3.14159.26","name":"JP Mens","nada":null,"coffee":true} (pretty-print) : $ jo -p -a * [ "Makefile", "README.md", "jo.1", "jo.c", "jo.pandoc", "json.c", "json.h" ] JSON . ... $ 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 { "name": "JP", "object": { "fruit": "Orange", "hungry": false, "point": { "x": 10, "y": 20, "list": [ 1, 2, 3, 4, 5 ] }, "number": 17 }, "sunday": false } ( switch -B "true" "false" "null" ): $ jo switch=true morning@0 {"switch":true,"morning":false} $ jo -B switch=true morning@0 {"switch":"true","morning":false} ( ) . point geo : $ jo -p name=Jane point[]=1 point[]=2 geo[lat]=10 geo[lon]=20 { "name": "Jane", "point": [ 1, 2 ], "geo": { "lat": 10, "lon": 20 } } (object paths): $ jo -p -d. name=Jane point[]=1 point[]=2 geo.lat=10 geo.lon=20 { "name": "Jane", "point": [ 1, 2 ], "geo": { "lat": 10, "lon": 20 } } -d : $ jo -p name=Jane point[]=1 point[]=2 geo.lat=10 geo.lon=20 { "name": "Jane", "point": [ 1, 2 ], "geo.lat": 10, "geo.lon": 20 } : $ jo < /dev/null {} $ MY_ARRAY=(a=1 b=2) $ jo -a "${MY_ARRAY[@]}" < /dev/null ["a=1","b=2"] (Type coercion): $ 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" { "a": "true", "b": true, "c": "123", "d": 123, "e": true, "f": true, "g": 14, "h": true } $ jo -a -- -s 123 -n "This is a test" -b C_Rocks 456 ["123",14,true,456] : @ % base64 : JSON : $ jo program=jo authors=@AUTHORS {"program":"jo","authors":"Jan-Piet Mens "} $ jo filename=AUTHORS content=%AUTHORS {"filename":"AUTHORS","content":"SmFuLVBpZXQgTWVucyA8anBtZW5zQGdtYWlsLmNvbT4K"} $ jo nested=:nested.json {"nested":{"field1":123,"field2":"abc"}} (escape) : $ jo name="JP Mens" twitter='\@jpmens' {"name":"JP Mens","twitter":"@jpmens"} $ jo char=" " URIescape=\\%20 {"char":" ","URIescape":"%20"} $ jo action="split window" vimcmd="\:split" {"action":"split window","vimcmd":":split"} ARG_MAX : $ ls | jo -a > child.json $ jo files:=child.json {"files":["AUTHORS","COPYING","ChangeLog" .... $ ls *.c | jo -a > source.json; ls *.h | jo -a > headers.json $ jo -a :source.json :headers.json [["base64.c","jo.c","json.c"],["base64.h","json.h"]] JSON : $ jo -f source.json 1 | jo -f - 2 3 ["base64.c","jo.c","json.c",1,2,3] $ curl -s 'https://noembed.com/embed?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ' | jo -f - status=Rickrolled { ...., "type":"video","author_url":"https://www.youtube.com/user/RickAstleyVEVO","status":"Rickrolled"} (jo ): $ jo a=1 b=2 a=3 {"a":1,"b":2,"a":3} $ jo -D a=1 b=2 a=3 {"a":3,"b":2} (OPTIONS) jo . -a words . -B jo "true" "false" true false "null" null . . -D . -e stdin ( stdin ). -n . -p (Pretty-print) JSON . -v . -V JSON ..SH " (BUGS)" . jo jo null stdin . . . jo . : $ jo a=1.0 {"a":1} $ jo a=\"1.0\" {"a":"1.0"} . . (EXIT STATUS) jo 0 . (AVAILABILITY) (CREDITS) o json.[ch] Joseph A. Adams . (SEE ALSO) o o o o strtod(3) (AUTHORS) Jan-Piet Mens User Manuals JO(1)