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,
15       occasionally, the PREV item of the stack. Commands that require a
16       specific type of value will indicate it in parentheses. For example:
17       "TOP (arr.)".
18
19       This program returns 0 on success or the index of the option which
20       failed.
21

OPTIONS

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

EXAMPLES

118       Extract the alg parameter from a JWE Protected Header:
119
120           $ jose fmt -j "$jwe" -Og protected -yOg alg -Su-
121           A128KW
122
123       List all JWKs in a JWKSet (one per line):
124
125           $ echo "$jwkset" | jose fmt -j- -Og keys -Af-
126           {"kty":"oct",...}
127           {"kty":"EC",...}
128
129       Change the algorithm in a JWK:
130
131           $ echo "$jwk" | jose fmt -j- -j '"A128GCM"' -s alg -Uo-
132           {"kty":"oct","alg":"A128GCM",...}
133
134       Build a JWE template:
135
136           $ jose fmt -j '{}' -cs unprotected -q A128KW -s alg -UUo-
137           {"unprotected":{"alg":"A128KW"}}
138

AUTHOR

140       Nathaniel McCallum <npmccallum@redhat.com>
141
142
143
144                                  07/20/2023                       JOSE-FMT(1)
Impressum