jose-fmt.1.adoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. jose-fmt(1)
  2. ===========
  3. :doctype: manpage
  4. == NAME
  5. jose-fmt - Converts JSON between serialization formats
  6. == SYNOPSIS
  7. *jose fmt* [OPTIONS]
  8. == OVERVIEW
  9. This *jose fmt* command provides a mechanism for building and parsing JSON
  10. objects from the command line. It operates as a simple stack machine. All
  11. commands operate on the TOP item of the stack and, occasionally, the PREV item
  12. of the stack. Commands that require a specific type of value will indicate it
  13. in parentheses. For example: "TOP (arr.)".
  14. This program returns 0 on success or the index of the option which failed.
  15. == OPTIONS
  16. * *-0*, *--null* :
  17. Assert TOP to be null
  18. * *-a*, *--append* :
  19. Append TOP to the end of PREV (arr.)
  20. * *-a*, *--append* :
  21. Set missing values from TOP (obj.) into PREV (obj.)
  22. * *-A*, *--array* :
  23. Assert TOP to be an array
  24. * *-B*, *--boolean* :
  25. Assert TOP to be a boolean
  26. * *-c*, *--copy* :
  27. Deep copy TOP, push onto TOP
  28. * *-d* _NAME_, *--delete*=_NAME_ :
  29. Delete NAME from TOP (obj.)
  30. * *-d* #, *--delete*=# :
  31. Delete # from TOP (arr.)
  32. * *-d* -#, *--delete*=-# :
  33. Delete # from the end of TOP (arr.)
  34. * *-e*, *--empty* :
  35. Erase all items from TOP (arr./obj.)
  36. * *-E*, *--equal* :
  37. Assert TOP to be equal to PREV
  38. * *-f* _FILE_, *--foreach*=_FILE_ :
  39. Write TOP (obj./arr.) to FILE, one line/item
  40. * *-f* -, *--foreach*=- :
  41. Write TOP (obj./arr.) to STDOUT, one line/item
  42. * *-F*, *--false* :
  43. Assert TOP to be false
  44. * *-g* _NAME_, *--get*=_NAME_ :
  45. Get item with NAME from TOP (obj.), push to TOP
  46. * *-g* #, *--get*=# :
  47. Get # item from TOP (arr.), push to TOP
  48. * *-g* -#, *--get*=-# :
  49. Get # item from the end of TOP (arr.), push to TOP
  50. * *-i* #, *--insert*=# :
  51. Insert TOP into PREV (arr.) at #
  52. * *-I*, *--integer* :
  53. Assert TOP to be an integer
  54. * *-j* _JSON_, *--json*=_JSON_ :
  55. Parse JSON constant, push onto TOP
  56. * *-j* _FILE_, *--json*=_FILE_ :
  57. Read from FILE, push onto TOP
  58. * *-j* -, *--json*=- :
  59. Read from STDIN, push onto TOP
  60. * *-l*, *--length* :
  61. Push length of TOP (arr./str./obj.) to TOP
  62. * *-M* #, *--move*=# :
  63. Move TOP back # places on the stack
  64. * *-N*, *--number* :
  65. Assert TOP to be a number
  66. * *-o* _FILE_, *--output*=_FILE_ :
  67. Write TOP to FILE
  68. * *-o* -, *--output*=- :
  69. Write TOP to STDOUT
  70. * *-O*, *--object* :
  71. Assert TOP to be an object
  72. * *-q* _STR_, *--quote*=_STR_ :
  73. Convert STR to a string, push onto TOP
  74. * *-Q*, *--query* :
  75. Query the stack by deep copying and pushing onto TOP
  76. * *-R*, *--real* :
  77. Assert TOP to be a real
  78. * *-s* _NAME_, *--set*=_NAME_ :
  79. Sets TOP into PREV (obj.) with NAME
  80. * *-s* #, *--set*=# :
  81. Sets TOP into PREV (obj.) at #
  82. * *-s* -#, *--set*=-# :
  83. Sets TOP into PREV (obj.) at # from the end
  84. * *-S*, *--string* :
  85. Assert TOP to be a string
  86. * *-t* #, *--truncate*=# :
  87. Shrink TOP (arr.) to length #
  88. * *-t* -#, *--truncate*=-# :
  89. Discard last # items from TOP (arr.)
  90. * *-T*, *--true* :
  91. Assert TOP to be true
  92. * *-u* _FILE_, *--unquote*=_FILE_ :
  93. Write TOP (str.) to FILE without quotes
  94. * *-u* -, *--unquote*=- :
  95. Write TOP (str.) to STDOUT without quotes
  96. * *-U*, *--unwind* :
  97. Discard TOP from the stack
  98. * *-x*, *--extend* :
  99. Append items from TOP to the end of PREV (arr.)
  100. * *-x*, *--extend* :
  101. Set all values from TOP (obj.) into PREV (obj.)
  102. * *-X*, *--not* :
  103. Invert the following assertion
  104. * *-y*, *--b64load* :
  105. URL-safe Base64 decode TOP (str.), push onto TOP
  106. * *-Y*, *--b64dump* :
  107. URL-safe Base64 encode TOP, push onto TOP
  108. == EXAMPLES
  109. Extract the *alg* parameter from a JWE Protected Header:
  110. $ jose fmt -j "$jwe" -Og protected -yOg alg -Su-
  111. A128KW
  112. List all JWKs in a JWKSet (one per line):
  113. $ echo "$jwkset" | jose fmt -j- -Og keys -Af-
  114. {"kty":"oct",...}
  115. {"kty":"EC",...}
  116. Change the algorithm in a JWK:
  117. $ echo "$jwk" | jose fmt -j- -j '"A128GCM"' -s alg -Uo-
  118. {"kty":"oct","alg":"A128GCM",...}
  119. Build a JWE template:
  120. $ jose fmt -j '{}' -cs unprotected -q A128KW -s alg -UUo-
  121. {"unprotected":{"alg":"A128KW"}}
  122. == AUTHOR
  123. Nathaniel McCallum <npmccallum@redhat.com>