skip to Main Content

How to parse nested json to csv using command line

I want to parse a nested json to csv. The data looks similar to this. {"tables":[{"name":"PrimaryResult","columns":[{"name":"name","type":"string"},{"name":"id","type":"string"},{"name":"custom","type":"dynamic"}]"rows":[["Alpha","1","{"age":"23","number":"xyz"}]]]} I want csv file as: name id age number alpha 1 23 xyz I tried: jq -r ".tables | .[] | .columns | map(.name)|@csv"…

VIEW QUESTION

jq convert jsonlines to csv with header without slurp

a potentially huge json-lines file with objects of known structure is to be converted to csv with headers. example {"name":"name_0","value_a":"value_a_0","value_b":"val_b_0"} {"name":"name_1","value_a":"value_a_1","value_b":"val_b_1"} {"name":"name_2","value_a":"value_a_2","value_b":"val_b_2"} {"name":"name_3","value_a":"value_a_3","value_b":"val_b_3"} {"name":"name_4","value_a":"value_a_4","value_b":"val_b_4"} expected output "name","value_a","value_b" "name_0","value_a_0","val_b_0" "name_1","value_a_1","val_b_1" "name_2","value_a_2","val_b_2" "name_3","value_a_3","val_b_3" "name_4","value_a_4","val_b_4" currently tried (if (input_line_number == 1 ) then…

VIEW QUESTION

Update a json file using csv file contents

I've 2 files: changes.csv and sample.json. My csv file is like following: header "a", "b" "a11","b1" "a22","b2" "a33","b3" and the json file is like: [ {"a":"a1","b":"b1"}, {"a":"a2","b":"b2"}, {"a":"a3","b":"b3"}, {"a":"a4","b":"b4"} ] I need to write a jq command, which make changes…

VIEW QUESTION
Back To Top
Search