How to map an object to arrays so it can be converted to csv?

前端 未结 5 1698
抹茶落季
抹茶落季 2020-12-24 06:13

I\'m trying to convert an object that looks like this:

{
  \"123\" : \"abc\",
  \"231\" : \"dbh\",
  \"452\" : \"xyz\"
}

To csv that looks

5条回答
  •  执笔经年
    2020-12-24 06:55

    Try This give same output you want

    echo '{"123":"abc","231":"dbh","452":"xyz"}' | jq -r 'to_entries | .[] | "\"" + .key + "\",\"" + (.value | tostring)+ "\""'
    

提交回复
热议问题