jose-fmt.1 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. .\" generated with Ronn/v0.7.3
  2. .\" http://github.com/rtomayko/ronn/tree/0.7.3
  3. .
  4. .TH "JOSE\-FMT" "1" "June 2017" "" ""
  5. .
  6. .SH "NAME"
  7. \fBjose\-fmt\fR \- Converts JSON between serialization formats
  8. .
  9. .SH "SYNOPSIS"
  10. \fBjose fmt\fR \fIOPTIONS\fR
  11. .
  12. .SH "OVERVIEW"
  13. This \fBjose fmt\fR 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\.)"\.
  14. .
  15. .P
  16. This program returns 0 on success or the index of the option which failed\.
  17. .
  18. .SH "OPTIONS"
  19. .
  20. .TP
  21. \fB\-X\fR, \fB\-\-not\fR
  22. Invert the following assertion
  23. .
  24. .TP
  25. \fB\-O\fR, \fB\-\-object\fR
  26. Assert TOP to be an object
  27. .
  28. .TP
  29. \fB\-A\fR, \fB\-\-array\fR
  30. Assert TOP to be an array
  31. .
  32. .TP
  33. \fB\-S\fR, \fB\-\-string\fR
  34. Assert TOP to be a string
  35. .
  36. .TP
  37. \fB\-I\fR, \fB\-\-integer\fR
  38. Assert TOP to be an integer
  39. .
  40. .TP
  41. \fB\-R\fR, \fB\-\-real\fR
  42. Assert TOP to be a real
  43. .
  44. .TP
  45. \fB\-N\fR, \fB\-\-number\fR
  46. Assert TOP to be a number
  47. .
  48. .TP
  49. \fB\-T\fR, \fB\-\-true\fR
  50. Assert TOP to be true
  51. .
  52. .TP
  53. \fB\-F\fR, \fB\-\-false\fR
  54. Assert TOP to be false
  55. .
  56. .TP
  57. \fB\-B\fR, \fB\-\-boolean\fR
  58. Assert TOP to be a boolean
  59. .
  60. .TP
  61. \fB\-0\fR, \fB\-\-null\fR
  62. Assert TOP to be null
  63. .
  64. .TP
  65. \fB\-E\fR, \fB\-\-equal\fR
  66. Assert TOP to be equal to PREV
  67. .
  68. .TP
  69. \fB\-Q\fR, \fB\-\-query\fR
  70. Query the stack by deep copying and pushing onto TOP
  71. .
  72. .TP
  73. \fB\-M\fR #, \fB\-\-move\fR=#
  74. Move TOP back # places on the stack
  75. .
  76. .TP
  77. \fB\-U\fR, \fB\-\-unwind\fR
  78. Discard TOP from the stack
  79. .
  80. .TP
  81. \fB\-j\fR \fIJSON\fR, \fB\-\-json\fR=\fIJSON\fR
  82. Parse JSON constant, push onto TOP
  83. .
  84. .TP
  85. \fB\-j\fR \fIFILE\fR, \fB\-\-json\fR=\fIFILE\fR
  86. Read from FILE, push onto TOP
  87. .
  88. .TP
  89. \fB\-j\fR \-, \fB\-\-json\fR=\-
  90. Read from STDIN, push onto TOP
  91. .
  92. .TP
  93. \fB\-c\fR, \fB\-\-copy\fR
  94. Deep copy TOP, push onto TOP
  95. .
  96. .TP
  97. \fB\-q\fR \fISTR\fR, \fB\-\-quote\fR=\fISTR\fR
  98. Convert STR to a string, push onto TOP
  99. .
  100. .TP
  101. \fB\-o\fR \fIFILE\fR, \fB\-\-output\fR=\fIFILE\fR
  102. Write TOP to FILE
  103. .
  104. .TP
  105. \fB\-o\fR \-, \fB\-\-output\fR=\-
  106. Write TOP to STDOUT
  107. .
  108. .TP
  109. \fB\-f\fR \fIFILE\fR, \fB\-\-foreach\fR=\fIFILE\fR
  110. Write TOP (obj\./arr\.) to FILE, one line/item
  111. .
  112. .TP
  113. \fB\-f\fR \-, \fB\-\-foreach\fR=\-
  114. Write TOP (obj\./arr\.) to STDOUT, one line/item
  115. .
  116. .TP
  117. \fB\-u\fR \fIFILE\fR, \fB\-\-unquote\fR=\fIFILE\fR
  118. Write TOP (str\.) to FILE without quotes
  119. .
  120. .TP
  121. \fB\-u\fR \-, \fB\-\-unquote\fR=\-
  122. Write TOP (str\.) to STDOUT without quotes
  123. .
  124. .TP
  125. \fB\-t\fR #, \fB\-\-truncate\fR=#
  126. Shrink TOP (arr\.) to length #
  127. .
  128. .TP
  129. \fB\-t\fR \-#, \fB\-\-truncate\fR=\-#
  130. Discard last # items from TOP (arr\.)
  131. .
  132. .TP
  133. \fB\-i\fR #, \fB\-\-insert\fR=#
  134. Insert TOP into PREV (arr\.) at #
  135. .
  136. .TP
  137. \fB\-a\fR, \fB\-\-append\fR
  138. Append TOP to the end of PREV (arr\.)
  139. .
  140. .TP
  141. \fB\-a\fR, \fB\-\-append\fR
  142. Set missing values from TOP (obj\.) into PREV (obj\.)
  143. .
  144. .TP
  145. \fB\-x\fR, \fB\-\-extend\fR
  146. Append items from TOP to the end of PREV (arr\.)
  147. .
  148. .TP
  149. \fB\-x\fR, \fB\-\-extend\fR
  150. Set all values from TOP (obj\.) into PREV (obj\.)
  151. .
  152. .TP
  153. \fB\-d\fR \fINAME\fR, \fB\-\-delete\fR=\fINAME\fR
  154. Delete NAME from TOP (obj\.)
  155. .
  156. .TP
  157. \fB\-d\fR #, \fB\-\-delete\fR=#
  158. Delete # from TOP (arr\.)
  159. .
  160. .TP
  161. \fB\-d\fR \-#, \fB\-\-delete\fR=\-#
  162. Delete # from the end of TOP (arr\.)
  163. .
  164. .TP
  165. \fB\-l\fR, \fB\-\-length\fR
  166. Push length of TOP (arr\./str\./obj\.) to TOP
  167. .
  168. .TP
  169. \fB\-e\fR, \fB\-\-empty\fR
  170. Erase all items from TOP (arr\./obj\.)
  171. .
  172. .TP
  173. \fB\-g\fR \fINAME\fR, \fB\-\-get\fR=\fINAME\fR
  174. Get item with NAME from TOP (obj\.), push to TOP
  175. .
  176. .TP
  177. \fB\-g\fR #, \fB\-\-get\fR=#
  178. Get # item from TOP (arr\.), push to TOP
  179. .
  180. .TP
  181. \fB\-g\fR \-#, \fB\-\-get\fR=\-#
  182. Get # item from the end of TOP (arr\.), push to TOP
  183. .
  184. .TP
  185. \fB\-s\fR \fINAME\fR, \fB\-\-set\fR=\fINAME\fR
  186. Sets TOP into PREV (obj\.) with NAME
  187. .
  188. .TP
  189. \fB\-s\fR #, \fB\-\-set\fR=#
  190. Sets TOP into PREV (obj\.) at #
  191. .
  192. .TP
  193. \fB\-s\fR \-#, \fB\-\-set\fR=\-#
  194. Sets TOP into PREV (obj\.) at # from the end
  195. .
  196. .TP
  197. \fB\-y\fR, \fB\-\-b64load\fR
  198. URL\-safe Base64 decode TOP (str\.), push onto TOP
  199. .
  200. .TP
  201. \fB\-Y\fR, \fB\-\-b64dump\fR
  202. URL\-safe Base64 encode TOP, push onto TOP
  203. .
  204. .SH "EXAMPLES"
  205. Extract the \fBalg\fR parameter from a JWE Protected Header:
  206. .
  207. .IP "" 4
  208. .
  209. .nf
  210. $ jose fmt \-j "$jwe" \-Og protected \-yOg alg \-Su\-
  211. A128KW
  212. .
  213. .fi
  214. .
  215. .IP "" 0
  216. .
  217. .P
  218. List all JWKs in a JWKSet (one per line):
  219. .
  220. .IP "" 4
  221. .
  222. .nf
  223. $ echo "$jwkset" | jose fmt \-j\- \-Og keys \-Af\-
  224. {"kty":"oct",\.\.\.}
  225. {"kty":"EC",\.\.\.}
  226. .
  227. .fi
  228. .
  229. .IP "" 0
  230. .
  231. .P
  232. Change the algorithm in a JWK:
  233. .
  234. .IP "" 4
  235. .
  236. .nf
  237. $ echo "$jwk" | jose fmt \-j\- \-j \'"A128GCM"\' \-s alg \-Uo\-
  238. {"kty":"oct","alg":"A128GCM",\.\.\.}
  239. .
  240. .fi
  241. .
  242. .IP "" 0
  243. .
  244. .P
  245. Build a JWE template:
  246. .
  247. .IP "" 4
  248. .
  249. .nf
  250. $ jose fmt \-j \'{}\' \-cs unprotected \-q A128KW \-s alg \-UUo\-
  251. {"unprotected":{"alg":"A128KW"}}
  252. .
  253. .fi
  254. .
  255. .IP "" 0
  256. .
  257. .SH "AUTHOR"
  258. Nathaniel McCallum <npmccallum@redhat\.com>