1JOSE-FMT(1)                                                        JOSE-FMT(1)
2
3
4

NAME

6       jose-fmt - Converts JSON between serialization formats
7

SYNOPSIS

9       jose fmt OPTIONS
10

OVERVIEW

12       This  jose  fmt  command  provides a mechanism for building and parsing
13       JSON objects from the command line.  It  operates  as  a  simple  stack
14       machine.  All  commands operate on the TOP item of the stack and, occa‐
15       sionally, the PREV item of the stack. Commands that require a  specific
16       type  of  value  will  indicate  it  in  parentheses. For example: "TOP
17       (arr.)".
18
19       This program returns 0 on success or the  index  of  the  option  which
20       failed.
21

OPTIONS

23       -X, --not
24              Invert the following assertion
25
26       -O, --object
27              Assert TOP to be an object
28
29       -A, --array
30              Assert TOP to be an array
31
32       -S, --string
33              Assert TOP to be a string
34
35       -I, --integer
36              Assert TOP to be an integer
37
38       -R, --real
39              Assert TOP to be a real
40
41       -N, --number
42              Assert TOP to be a number
43
44       -T, --true
45              Assert TOP to be true
46
47       -F, --false
48              Assert TOP to be false
49
50       -B, --boolean
51              Assert TOP to be a boolean
52
53       -0, --null
54              Assert TOP to be null
55
56       -E, --equal
57              Assert TOP to be equal to PREV
58
59       -Q, --query
60              Query the stack by deep copying and pushing onto TOP
61
62       -M #, --move=#
63              Move TOP back # places on the stack
64
65       -U, --unwind
66              Discard TOP from the stack
67
68       -j JSON, --json=JSON
69              Parse JSON constant, push onto TOP
70
71       -j FILE, --json=FILE
72              Read from FILE, push onto TOP
73
74       -j -, --json=-
75              Read from STDIN, push onto TOP
76
77       -c, --copy
78              Deep copy TOP, push onto TOP
79
80       -q STR, --quote=STR
81              Convert STR to a string, push onto TOP
82
83       -o FILE, --output=FILE
84              Write TOP to FILE
85
86       -o -, --output=-
87              Write TOP to STDOUT
88
89       -f FILE, --foreach=FILE
90              Write TOP (obj./arr.) to FILE, one line/item
91
92       -f -, --foreach=-
93              Write TOP (obj./arr.) to STDOUT, one line/item
94
95       -u FILE, --unquote=FILE
96              Write TOP (str.) to FILE without quotes
97
98       -u -, --unquote=-
99              Write TOP (str.) to STDOUT without quotes
100
101       -t #, --truncate=#
102              Shrink TOP (arr.) to length #
103
104       -t -#, --truncate=-#
105              Discard last # items from TOP (arr.)
106
107       -i #, --insert=#
108              Insert TOP into PREV (arr.) at #
109
110       -a, --append
111              Append TOP to the end of PREV (arr.)
112
113       -a, --append
114              Set missing values from TOP (obj.) into PREV (obj.)
115
116       -x, --extend
117              Append items from TOP to the end of PREV (arr.)
118
119       -x, --extend
120              Set all values from TOP (obj.) into PREV (obj.)
121
122       -d NAME, --delete=NAME
123              Delete NAME from TOP (obj.)
124
125       -d #, --delete=#
126              Delete # from TOP (arr.)
127
128       -d -#, --delete=-#
129              Delete # from the end of TOP (arr.)
130
131       -l, --length
132              Push length of TOP (arr./str./obj.) to TOP
133
134       -e, --empty
135              Erase all items from TOP (arr./obj.)
136
137       -g NAME, --get=NAME
138              Get item with NAME from TOP (obj.), push to TOP
139
140       -g #, --get=#
141              Get # item from TOP (arr.), push to TOP
142
143       -g -#, --get=-#
144              Get # item from the end of TOP (arr.), push to TOP
145
146       -s NAME, --set=NAME
147              Sets TOP into PREV (obj.) with NAME
148
149       -s #, --set=#
150              Sets TOP into PREV (obj.) at #
151
152       -s -#, --set=-#
153              Sets TOP into PREV (obj.) at # from the end
154
155       -y, --b64load
156              URL-safe Base64 decode TOP (str.), push onto TOP
157
158       -Y, --b64dump
159              URL-safe Base64 encode TOP, push onto TOP
160

EXAMPLES

162       Extract the alg parameter from a JWE Protected Header:
163
164
165
166           $ jose fmt -j "$jwe" -Og protected -yOg alg -Su-
167           A128KW
168
169
170
171       List all JWKs in a JWKSet (one per line):
172
173
174
175           $ echo "$jwkset" | jose fmt -j- -Og keys -Af-
176           {"kty":"oct",...}
177           {"kty":"EC",...}
178
179
180
181       Change the algorithm in a JWK:
182
183
184
185           $ echo "$jwk" | jose fmt -j- -j ´"A128GCM"´ -s alg -Uo-
186           {"kty":"oct","alg":"A128GCM",...}
187
188
189
190       Build a JWE template:
191
192
193
194           $ jose fmt -j ´{}´ -cs unprotected -q A128KW -s alg -UUo-
195           {"unprotected":{"alg":"A128KW"}}
196
197
198

AUTHOR

200       Nathaniel McCallum <npmccallum@redhat.com>
201
202
203
204                                   June 2017                       JOSE-FMT(1)
Impressum