How to copy a JSON document inside another using jq

我的梦境 提交于 2019-12-02 23:02:14

问题


How can I transform a JSON document like this:

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

into something like this:

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

using the command line tool jq?


回答1:


You just need to wrap an object around the input.

jq '{payload: .}' some.json


来源:https://stackoverflow.com/questions/53125290/how-to-copy-a-json-document-inside-another-using-jq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!