Skip to content
Kelly Brazil edited this page May 17, 2022 · 15 revisions

Generic Converters

jc comes with a few generic or standard-format converters, including:

  • CSV
  • INI
  • Key/Value
  • XML
  • YAML

Sometimes commands will output in one of these supported formats for easy conversion to JSON.

For example, you can parse the HTTP headers from curl using the Key/Value parser:

$ curl --silent --header "origin: https://origin.example.com" \
       --request GET "https://cors-test.appspot.com/test" \
       --head | jc --kv -p
{
  "http/2 200": "",
  "cache-control": "no-cache",
  "access-control-allow-origin": "https://origin.example.com",
  "access-control-max-age": "0",
  "access-control-allow-credentials": "true",
  "set-cookie": "test=test",
  "expires": "Fri, 01 Jan 1990 00:00:00 GMT",
  "content-type": "application/json",
  "x-cloud-trace-context": "086f2570a400102ed316c10f1719c87e",
  "date": "Tue, 17 May 2022 21:39:06 GMT",
  "server": "Google Frontend",
  "content-length": "15",
  "alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
}
Clone this wiki locally