Basically, I have the following object created by JSON:
({ "id" : 3, "clientName" : "Avia", "monthlyactiveusers" : 2083, "dailynewlikes" : 0, "totallikes" : 4258, "usersgraph" : { "sTotalLikes" : [{ "likes" : 79, "date" : "1/1/2010" }, { "likes" : 116, "date" : "1/1/2010" }], "sDailyActiveUsers" : [{ "likes" : 79, "date" : "1/1/2010" }, { "likes" : 116, "date" : "1/1/2010" }] } });
And I need the following result:
sTotalLikes = [['1/1/2010', 79],['1/1/2010', 79],['1/11/2010', 79]]; sDailyActiveUsers = [['1/1/2010', 10],['1/5/2010', 300],['1/11/2010', 220]];
I know that you can iterate through an object to build an array using the following code, but I could not figure out how to build the JavaScript array itself. Thank you in advance.
var sTotalLikes = new Array(); for (var i = 0; i < usersgraph.sTotalLikes.length; i++) {
json javascript jquery object arrays
Vasile Laur
source share