您好我正在尝试使用jq
解析哈希{
"name": "a",
"data": [
{
"sensitive": false,
"type": "string",
"value": "mykeypair"
},
{
"sensitive": false,
"type": "int",
"value": 123
}
]
}
并获得类似
的输出a,string,mykeypair
a,int,123
我能够得到像这样的输出
a,string,mykeypair
a,int,mykeypair
a,string,123
a,int,123
答案 0 :(得分:3)
jq
解决方案:
jq -r '.name as $n | .data[] | [$n, .type, .value] | @csv' file.json
输出:
"a","string","mykeypair"
"a","int",123
如果必须输出不带引号的值:
jq -r '.name as $n | .data[] | [$n, .type, "\(.value)"] | join(",")' file.json
输出:
a,string,mykeypair
a,int,123