I have a javascript code like this:
var myData=[];
$.getJSON( path_url , function(data){
var len = data.rows.length;
for (var i = 0; i < len; i++){
var code = data.rows[i].codeid;
var color = data.rows[i].color;
var obj = {}
obj[code] = color
myData.push(obj);
}
console.log(myData);
});
and the results
0: Object{12: "#fc0516"},1: Object{14: "#17a030"},2: Object{31: "#17a030"}
but the results I would like this:
{12:"#fc0516",14:"#17a030",31:"#17a030"}
how can I get the result as above? sorry for my bad english, thanks in advance...