I d like to default values in place on jq, and return root document.
What I have (note that some property is missing from the inner object):
[{"foo":{}},{"foo":{"a":1}},{"foo":{"b":4,"c":23}},{"foo":{"a":15,"b":2,"c":33}}]
What I want (default missing property with 0
):
[
{
"foo": {
"a": 0,
"b": 0,
"c": 0
}
},
{
"foo": {
"a": 1,
"b": 0,
"c": 0,
}
},
{
"foo": {
"a": 0,
"b": 4,
"c": 23
}
},
{
"foo": {
"a": 15,
"b": 2,
"c": 33
}
}
]
I ve tried something like jq .[] | (.foo | getpath(["a"]) //= 0) < in > out
, but this returns stream of the inner object instead of root document; this is not what I wanted because there are other property to grouping record, I would like to group by it later.