Skip to main content
added 46 characters in body
Source Link
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","f3""tenant","f4"]"vpc"] ,      ### the csv header
(.peerings[]              ##          ### for all in peerings list
  | [ .name, 
      .id, 
      (.accept_vpc_info | [ .tenant_id, 
 .vpc_id ])
    ].accept_vpc_info.vpc_id 
  |flatten
)  ]
) | @csv
  1. run it!
$  jq -rf x.jq  ex.json 
"name","id","f1""tenant","f2""vpc"
"NAME1","0b19d","184a5","0d11f"
"NAME2","0d34a","067eb","17944"
"NAME3","173e2","0ae21","071c4"

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","f3","f4"],
(.peerings[]              ## for all in peerings list
  | [ .name, 
      .id, 
      (.accept_vpc_info | [ .tenant_id, .vpc_id ])
    ] 
  |flatten
)   | @csv
  1. run it!
$  jq -rf x.jq  ex.json 
"name","id","f1","f2"
"NAME1","0b19d","184a5","0d11f"
"NAME2","0d34a","067eb","17944"
"NAME3","173e2","0ae21","071c4"

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"
added 65 characters in body
Source Link
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","f3","f4"],
(.peerings[]              ## for all in peerings list
  | [ .name, 
      .id, 
      (.accept_vpc_info | [ .tenant_id, .vpc_id ])
    ] 
  |flatten
)   | @csv
  1. run it!
$  jq -rf x.jq  ex.json 
"name","id","f1","f2"
"NAME1","0b19d","184a5","0d11f"
"NAME2","0d34a","067eb","17944"
"NAME3","173e2","0ae21","071c4"

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"
.peerings[]              ## for all in peerings list
  | [ .name, 
      .id, 
      (.accept_vpc_info | [ .tenant_id, .vpc_id ])
    ] 
  |flatten | @csv
  1. run it!
$  jq -rf x.jq  ex.json 
"NAME1","0b19d","184a5","0d11f"
"NAME2","0d34a","067eb","17944"
"NAME3","173e2","0ae21","071c4"

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","f3","f4"],
(.peerings[]              ## for all in peerings list
  | [ .name, 
      .id, 
      (.accept_vpc_info | [ .tenant_id, .vpc_id ])
    ] 
  |flatten
)   | @csv
  1. run it!
$  jq -rf x.jq  ex.json 
"name","id","f1","f2"
"NAME1","0b19d","184a5","0d11f"
"NAME2","0d34a","067eb","17944"
"NAME3","173e2","0ae21","071c4"
added 88 characters in body
Source Link
JJoao
  • 12.8k
  • 1
  • 26
  • 45

With jq you could run something along the lines of:

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

With jq you could run something along the lines of:

  1. create a jq filter "x.jq"
.peerings[] 
  | [ .name, 
      .id, 
      (.accept_vpc_info | [ .tenant_id, .vpc_id ])
    ] 
  |flatten | @csv
  1. run it!
$  jq -rf x.jq  ex.json 
"NAME1","0b19d","184a5","0d11f"
"NAME2","0d34a","067eb","17944"
"NAME3","173e2","0ae21","071c4"

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"
.peerings[]              ## for all in peerings list
  | [ .name, 
      .id, 
      (.accept_vpc_info | [ .tenant_id, .vpc_id ])
    ] 
  |flatten | @csv
  1. run it!
$  jq -rf x.jq  ex.json 
"NAME1","0b19d","184a5","0d11f"
"NAME2","0d34a","067eb","17944"
"NAME3","173e2","0ae21","071c4"
Source Link
JJoao
  • 12.8k
  • 1
  • 26
  • 45
Loading