javascript - divide json on 2 arrays -


i try divide json array:

 var json = [{"date":"23","count":"100"},{"date":"23","count":"100"}]  var labels = [],data=[];  for(var in json){       labels.push(json[i].date);       data.push(json[i].count);   }   alert(labels); 

but in alert , problem ? there https://jsfiddle.net/90597hzy/

json not have date & count key

replaced name & label. working expected

var json = [{"name":"23","label":"100"},                {"name":"23","label":"100"}]              var labels = [],data=[];              for(var in json){                   labels.push(json[i].name);                   data.push(json[i].label);               }               console.log(labels); 

jsfiddle


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -