I would like to modify something like the following JSON:
{
"foobar": {
"a": {
"adkjfe": {
"A": 1,
"foo": "bar"
}
},
"b": {
"ekjaei": {
"A": 2,
"bar": "foo"
}
}
}
}
to add more data say {"baz": ["bing", "bop"]} to the parent of A if A=1. Assuming I don't know the parent key while leaving the rest of the json untouched. I've tried many different things including:
.foobar | .. | .. | .[] | if select(.A==1) then . += {"baz": "bing"} else . end
which gives me an error and only my modified section.
The result, in this case, that I would like to see is:
{
"foobar": {
"a": {
"adkjfe": {
"A": 1,
"foo": "bar",
"baz": ["bing", "bop"]
}
},
"b": {
"ekjaei": {
"A": 2,
"bar": "foo"
}
}
}
}