Below is my JSON
[
{
"id": "0",
"bucket_attr1": "test1",
"buckets": ["abc", "def", "mhf"]
},
{
"id": "1",
"bucket_attr1": "test2",
"buckets": ["abc", "ghi"]
}
]
I want to copy id and bucket_attr1 into each map in the buckets array, such that output is as follows
[
{
"bucket_id": "abc",
"bucket_attr1": "test1",
"id": "0"
},
{
"bucket_id": "def",
"bucket_attr1": "test1",
"id": "0"
},
{
"bucket_id": "mhf",
"bucket_attr1": "test1",
"id": "0"
}
{
"bucket_id": "abc",
"bucket_attr2": "test2",
"id": "1"
},
{
"bucket_id": "ghi",
"bucket_attr2": "test2",
"id": "1"
}
]
I tried several ways including what is mentioned here after slight modification, but it did not work. Jolt Transformation to move an attribute in each element of the array
New contributor
Shashi Kiran GM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.