JOSE-FMT(1) JOSE-FMT(1) NAME jose-fmt - Converts JSON between serialization formats SYNOPSIS jose fmt [OPTIONS] OVERVIEW This jose fmt command provides a mechanism for building and parsing JSON objects from the command line. It operates as a simple stack machine. All commands operate on the TOP item of the stack and, occasionally, the PREV item of the stack. Commands that require a specific type of value will indicate it in parentheses. For example: "TOP (arr.)". This program returns 0 on success or the index of the option which failed. OPTIONS o -0, --null : Assert TOP to be null o -a, --append : Append TOP to the end of PREV (arr.) o -a, --append : Set missing values from TOP (obj.) into PREV (obj.) o -A, --array : Assert TOP to be an array o -B, --boolean : Assert TOP to be a boolean o -c, --copy : Deep copy TOP, push onto TOP o -d NAME, --delete=NAME : Delete NAME from TOP (obj.) o -d , --delete= : Delete # from TOP (arr.) o -d -, --delete=- : Delete # from the end of TOP (arr.) o -e, --empty : Erase all items from TOP (arr./obj.) o -E, --equal : Assert TOP to be equal to PREV o -f FILE, --foreach=FILE : Write TOP (obj./arr.) to FILE, one line/item o -f -, --foreach=- : Write TOP (obj./arr.) to STDOUT, one line/item o -F, --false : Assert TOP to be false o -g NAME, --get=NAME : Get item with NAME from TOP (obj.), push to TOP o -g , --get= : Get # item from TOP (arr.), push to TOP o -g -, --get=- : Get # item from the end of TOP (arr.), push to TOP o -i , --insert= : Insert TOP into PREV (arr.) at # o -I, --integer : Assert TOP to be an integer o -j JSON, --json=JSON : Parse JSON constant, push onto TOP o -j FILE, --json=FILE : Read from FILE, push onto TOP o -j -, --json=- : Read from STDIN, push onto TOP o -l, --length : Push length of TOP (arr./str./obj.) to TOP o -M , --move= : Move TOP back # places on the stack o -N, --number : Assert TOP to be a number o -o FILE, --output=FILE : Write TOP to FILE o -o -, --output=- : Write TOP to STDOUT o -O, --object : Assert TOP to be an object o -q STR, --quote=STR : Convert STR to a string, push onto TOP o -Q, --query : Query the stack by deep copying and pushing onto TOP o -R, --real : Assert TOP to be a real o -s NAME, --set=NAME : Sets TOP into PREV (obj.) with NAME o -s , --set= : Sets TOP into PREV (obj.) at # o -s -, --set=- : Sets TOP into PREV (obj.) at # from the end o -S, --string : Assert TOP to be a string o -t , --truncate= : Shrink TOP (arr.) to length # o -t -, --truncate=- : Discard last # items from TOP (arr.) o -T, --true : Assert TOP to be true o -u FILE, --unquote=FILE : Write TOP (str.) to FILE without quotes o -u -, --unquote=- : Write TOP (str.) to STDOUT without quotes o -U, --unwind : Discard TOP from the stack o -x, --extend : Append items from TOP to the end of PREV (arr.) o -x, --extend : Set all values from TOP (obj.) into PREV (obj.) o -X, --not : Invert the following assertion o -y, --b64load : URL-safe Base64 decode TOP (str.), push onto TOP o -Y, --b64dump : URL-safe Base64 encode TOP, push onto TOP EXAMPLES Extract the alg parameter from a JWE Protected Header: $ jose fmt -j "$jwe" -Og protected -yOg alg -Su- A128KW List all JWKs in a JWKSet (one per line): $ echo "$jwkset" | jose fmt -j- -Og keys -Af- {"kty":"oct",...} {"kty":"EC",...} Change the algorithm in a JWK: $ echo "$jwk" | jose fmt -j- -j '"A128GCM"' -s alg -Uo- {"kty":"oct","alg":"A128GCM",...} Build a JWE template: $ jose fmt -j '{}' -cs unprotected -q A128KW -s alg -UUo- {"unprotected":{"alg":"A128KW"}} AUTHOR Nathaniel McCallum 11/01/2022 JOSE-FMT(1)