像json一样
[
{
"parent": "x",
"children": ["a", "b"]
},
{
"parent": "y",
"children": ["c", "d", "e"]
}
]
如何使用jq将其转换为“ [parent,child_order_number,child]”项数组,例如
[
["x", 0, "a"],
["x", 1, "b"],
["y", 0, "c"],
["y", 1, "d"],
["y", 2, "e"]
]
?
答案 0 :(得分:1)
console.log('Type of test:', typeof test);
产量:
jq -c '[.[] | range(.children|length) as $i | [.parent, $i, .children[$i]]]' file