Convert a JSON into CSV using jq

前端 未结 2 1023
感动是毒
感动是毒 2021-01-27 12:49

I have a json file, which is stored in an environment variable temp.

{ \"users\": [ { \"username\": \"jack\", \"email\": \"jack@somewhere.com\",

2条回答
  •  清歌不尽
    2021-01-27 13:15

    You need to quote your column names, especially since they contain spaces and dashes. However you need to escape the quotes for bash:

    jq --raw-output '.users[] | [.username, .email, ."total running apps", ."api-mock-app", ."flogo", ."ipaas", ."nodejs-app"] | @csv'
    

提交回复
热议问题