I would like to add values that get from an external http call to the payload, but before I should remove the objects from the array, I tried to use the reduce function but the result are not what i expected.
The payload looks like this
[
{
"foo": "bar"
},
{
"bar": "foo"
}
]
the value i am getting from the http call is an array :
[
{
"ssrCode": "x1",
"ssrdescription": "main client"
},
{
"ssrCode": "x2",
"ssrdescription": "authorized"
}
]
the final result should be just the objects into the original payload
[{
"foo": "bar"
},
{
"ssrCode": "x1",
"ssrdescription": "main client"
},
{
"ssrCode": "x2",
"ssrdescription": "authorized"
} {
"bar": "foo"
}
]
The below reduce add all the same objects to the same {} instead of separate
payload reduce ((v, acc = {} ) -> acc ++ v)
{
"ssrCode": "x1",
"ssrdescription": "main client",
"ssrCode": "x2",
"ssrdescription": "authorized"
}
Anyone can help me with that?