I have an array of object with duplicate name object (here "Letter").
I need to merge objects named "Letter" as an array of the Values.
How can I manage it with jquery ?
FYI, the object come from a form "$(form).serializeArray()" with mutiple option in select
Original :
[
{
"name": "Hello",
"value": "World"
},
{
"name": "Letter",
"value": "A"
},
{
"name": "Letter",
"value": "B"
}
]
Expected :
[
{
"name": "Hello",
"value": "World"
},
{
"name": "Letter",
"value": [
"A",
"B"
]
}
]
2
Answers
I think this is what your after
I hope this helps
here is a minor tweek for you
Is this better ?