so I have a var data with a result array JSON value like this:
[
{"vehicle_id":"1", "model_name":"sedan"},
{"vehicle_id":"2", "model_name":"elf"},
{"vehicle_id":"3", "model_name":"truck"}
]
I want to set each value on new variable like this :
var newdata = [
{
text: Obj.model_name
value: Obj.vehicle_id
},
{
text: Obj.model_name
value: Obj.vehicle_id
},
......
];
How to set each value on the variable above ?
I already try this approach :
var newdata = [
$.each(data, function(index, Obj){
{
text: Obj.model_name
value: Obj.vehicle_id
}
})
];
But seems it's not working, can anyone have best practice of this case ?