问题描述
{
"test1": {
"type": "string","value": "foo"
},"test2": {
"type": "string","value": "bar"
}
}
在像上面这样的 json 中,我需要提取以下详细信息。假设我必须同时提取键和值。
test1=foo
test2=bar
无论如何这可以通过 bash 实现吗?
解决方法
找到答案了。您可以通过以下代码来完成。
jq -r 'keys[] as $k | "\($k) \(.[$k].value)"' tmp.json