How to copy a JSON document inside another using jq

前端 未结 1 1536
傲寒
傲寒 2021-01-28 05:35

How can I transform a JSON document like this:

{ \"foo\": 123, \"bar\": \"abc\" }

into something like this:

{ \"payload\":  { \         


        
相关标签:
1条回答
  • 2021-01-28 06:23

    You just need to wrap an object around the input.

    jq '{payload: .}' some.json
    
    0 讨论(0)
提交回复
热议问题