{
"prodid_876006": {
"serid": [{
"seridone": "3265874"
}, {
"seridtwo": "21458915"
}],
"serials": ["028915"]
},
"prodid_980": {
"serid": [{
"seridone": "32743214"
}, {
"seridtwo": "5469872"
}],
"serials": ["192147","1632589"]
}
}
% jq '[to_entries[] | {"key": .key, "value": .value.serials}] | from_entries' some.json
給出:transfrom一個JSON文件,到一個新的JSON
{
"prodid_876006": [
"028915"
],
"prodid_980": [
"192147",
"1632589"
]
}
我怎麼能得到下面的輸出? (這裏的關鍵是連續數組的每個元素,並且該值是樣品JSON的鍵):
{
"028915" : ["prodid_876006"],
"192147" : ["prodid_980"],
"1632589" : ["prodid_980"]
}
鑑於這個問題是[另一個你問](http://stackoverflow.com/q/42762941/78845)多麼相似,你可能會更好說明你正在試圖解決的問題,而比如何實施解決方案。另請參閱:https://meta.stackexchange.com/q/66377/147331 – Johnsyweb