How can I convert my JSON to CSV using jq?

前端 未结 5 1661
礼貌的吻别
礼貌的吻别 2020-12-28 17:25

I have the following JSON data:

{\"id\":\"111\",\"case\":\"Y\",\"custom\":{\"speech invoked\":\"no\",\"input method\":\"hard\",\"session ID\":\"420\"}}
         


        
5条回答
  •  不知归路
    2020-12-28 17:39

    Building upon Joe Harris' answer, you can use the @csv filter so that strings are properly quoted and escaped when necessary :

    jq -r '[.case, .custom."speech invoked", .custom."input method"] | @csv'
    

提交回复
热议问题