I have an array like this:-
[
{"brand":"cadbury","category":"silk"},
{"brand":"biba","category":"tops"},
{"brand":"cadbury","category":"fruitnut"}
]
And I want to convert it to below format, tried many ways to do but not succedded:-
[
{"brand":"cadbury","category":[{"name":"silk"},{"name":"fruitnut"}]},
{"brand":"biba","category": [{"name":"tops"}] }
]
Basically after loop I want to combine all brands together.