I have a json object which stores all the vehicle models with their brand.
[{
"brand":"Audi","model":"A4"
},
{
"brand":"Audi","model":"A6"
},
{
"brand":"BMW","model":"Z4"
},
{
"brand":"Audi","model":"R8"
},
{
"brand":"Volvo","model":"v40"
},
{
"brand":"BMW","model":"5 Series"
}]
But the problem is , If I have 3 models for Audi, then the list is repeating the brand again and again thus filling my list with duplicate values. So I need to make a json object something like this: I just want to make a json object as follows using javascript or angularjs:
[ {"brand":"Audi","models":["A4","A6","R8"]},
{"brand":"BMW","models":["Z4","5 Series"]},
{"brand":"Volvo","models":["v40"]}]