Skip to main content
4 of 4
added 46 characters in body
JJoao
  • 12.8k
  • 1
  • 26
  • 45

With jq you could run something along the lines of:

  1. (Assuming you want to select just some fields) create a jq filter "x.jq"
["name","id","tenant","vpc"] ,      ### the csv header
(.peerings[]                        ### for all in peerings list
  | [ .name,
      .id,
      .accept_vpc_info.tenant_id,
      .accept_vpc_info.vpc_id 
    ]
) | @csv
  1. run it!
$  jq -rf x.jq  ex.json 
"name","id","tenant","vpc"
"NAME1","0b19d","184a5","0d11f"
"NAME2","0d34a","067eb","17944"
"NAME3","173e2","0ae21","071c4"
JJoao
  • 12.8k
  • 1
  • 26
  • 45