'\" t .\" Title: jose-fmt .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.16 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" .TH "JOSE\-FMT" "1" "" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" jose-fmt \- Converts JSON between serialization formats .SH "SYNOPSIS" .sp \fBjose fmt\fP [OPTIONS] .SH "OVERVIEW" .sp This \fBjose fmt\fP 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.)". .sp This program returns 0 on success or the index of the option which failed. .SH "OPTIONS" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-0\fP, \fB\-\-null\fP : Assert TOP to be null .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-a\fP, \fB\-\-append\fP : Append TOP to the end of PREV (arr.) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-a\fP, \fB\-\-append\fP : Set missing values from TOP (obj.) into PREV (obj.) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-A\fP, \fB\-\-array\fP : Assert TOP to be an array .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-B\fP, \fB\-\-boolean\fP : Assert TOP to be a boolean .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-c\fP, \fB\-\-copy\fP : Deep copy TOP, push onto TOP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-d\fP \fINAME\fP, \fB\-\-delete\fP=\fINAME\fP : Delete NAME from TOP (obj.) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-d\fP , \fB\-\-delete\fP= : Delete # from TOP (arr.) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-d\fP \-, \fB\-\-delete\fP=\- : Delete # from the end of TOP (arr.) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-e\fP, \fB\-\-empty\fP : Erase all items from TOP (arr./obj.) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-E\fP, \fB\-\-equal\fP : Assert TOP to be equal to PREV .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-f\fP \fIFILE\fP, \fB\-\-foreach\fP=\fIFILE\fP : Write TOP (obj./arr.) to FILE, one line/item .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-f\fP \-, \fB\-\-foreach\fP=\- : Write TOP (obj./arr.) to STDOUT, one line/item .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-F\fP, \fB\-\-false\fP : Assert TOP to be false .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-g\fP \fINAME\fP, \fB\-\-get\fP=\fINAME\fP : Get item with NAME from TOP (obj.), push to TOP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-g\fP , \fB\-\-get\fP= : Get # item from TOP (arr.), push to TOP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-g\fP \-, \fB\-\-get\fP=\- : Get # item from the end of TOP (arr.), push to TOP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-i\fP , \fB\-\-insert\fP= : Insert TOP into PREV (arr.) at # .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-I\fP, \fB\-\-integer\fP : Assert TOP to be an integer .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-j\fP \fIJSON\fP, \fB\-\-json\fP=\fIJSON\fP : Parse JSON constant, push onto TOP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-j\fP \fIFILE\fP, \fB\-\-json\fP=\fIFILE\fP : Read from FILE, push onto TOP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-j\fP \-, \fB\-\-json\fP=\- : Read from STDIN, push onto TOP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-l\fP, \fB\-\-length\fP : Push length of TOP (arr./str./obj.) to TOP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-M\fP , \fB\-\-move\fP= : Move TOP back # places on the stack .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-N\fP, \fB\-\-number\fP : Assert TOP to be a number .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-o\fP \fIFILE\fP, \fB\-\-output\fP=\fIFILE\fP : Write TOP to FILE .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-o\fP \-, \fB\-\-output\fP=\- : Write TOP to STDOUT .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-O\fP, \fB\-\-object\fP : Assert TOP to be an object .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-q\fP \fISTR\fP, \fB\-\-quote\fP=\fISTR\fP : Convert STR to a string, push onto TOP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-Q\fP, \fB\-\-query\fP : Query the stack by deep copying and pushing onto TOP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-R\fP, \fB\-\-real\fP : Assert TOP to be a real .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-s\fP \fINAME\fP, \fB\-\-set\fP=\fINAME\fP : Sets TOP into PREV (obj.) with NAME .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-s\fP , \fB\-\-set\fP= : Sets TOP into PREV (obj.) at # .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-s\fP \-, \fB\-\-set\fP=\- : Sets TOP into PREV (obj.) at # from the end .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-S\fP, \fB\-\-string\fP : Assert TOP to be a string .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-t\fP , \fB\-\-truncate\fP= : Shrink TOP (arr.) to length # .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-t\fP \-, \fB\-\-truncate\fP=\- : Discard last # items from TOP (arr.) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-T\fP, \fB\-\-true\fP : Assert TOP to be true .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-u\fP \fIFILE\fP, \fB\-\-unquote\fP=\fIFILE\fP : Write TOP (str.) to FILE without quotes .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-u\fP \-, \fB\-\-unquote\fP=\- : Write TOP (str.) to STDOUT without quotes .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-U\fP, \fB\-\-unwind\fP : Discard TOP from the stack .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-x\fP, \fB\-\-extend\fP : Append items from TOP to the end of PREV (arr.) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-x\fP, \fB\-\-extend\fP : Set all values from TOP (obj.) into PREV (obj.) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-X\fP, \fB\-\-not\fP : Invert the following assertion .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-y\fP, \fB\-\-b64load\fP : URL\-safe Base64 decode TOP (str.), push onto TOP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fB\-Y\fP, \fB\-\-b64dump\fP : URL\-safe Base64 encode TOP, push onto TOP .RE .SH "EXAMPLES" .sp Extract the \fBalg\fP parameter from a JWE Protected Header: .sp .if n .RS 4 .nf .fam C $ jose fmt \-j "$jwe" \-Og protected \-yOg alg \-Su\- A128KW .fam .fi .if n .RE .sp List all JWKs in a JWKSet (one per line): .sp .if n .RS 4 .nf .fam C $ echo "$jwkset" | jose fmt \-j\- \-Og keys \-Af\- {"kty":"oct",...} {"kty":"EC",...} .fam .fi .if n .RE .sp Change the algorithm in a JWK: .sp .if n .RS 4 .nf .fam C $ echo "$jwk" | jose fmt \-j\- \-j \*(Aq"A128GCM"\*(Aq \-s alg \-Uo\- {"kty":"oct","alg":"A128GCM",...} .fam .fi .if n .RE .sp Build a JWE template: .sp .if n .RS 4 .nf .fam C $ jose fmt \-j \*(Aq{}\*(Aq \-cs unprotected \-q A128KW \-s alg \-UUo\- {"unprotected":{"alg":"A128KW"}} .fam .fi .if n .RE .SH "AUTHOR" .sp Nathaniel McCallum \c .MTO "npmccallum\(atredhat.com" "" ""