I have the following source JSON which I need to reshape:
{
"group": "A",
"name": "abc",
"events": [
{
"id": "54209",
"message": "foobar 1"
},
{
"id": "76548",
"message": "foobar 2"
}
]
}
{
"group": "B",
"name": "def",
"events": [
{
"id": "54593",
"message": "foobar 3"
},
{
"id": "20359",
"message": "foobar 4"
}
]
}
How can I get to the following output:
[
{
"group": "A",
"name": "abc",
"id": "54209",
"message": "foobar 1"
},
{
"group": "A",
"name": "abc",
"id": "76548",
"message": "foobar 2"
},
{
"group": "B",
"name": "def",
"id": "54593",
"message": "foobar 3"
},
{
"group": "B",
"name": "def",
"id": "20359",
"message": "foobar 4"
}
]
I basically want a single array with all the child event arrays, but with their parent objects embedded into them. I came very close with an example from this issue: https://github.com/stedolan/jq/issues/646. But I need the keys as well, not just the values.