javascript - Easy way to extract json object properties into an array? -


given following json object, there easy way extract values of results object properties?

var j={"success":true,        "msg":["clutch updated."],        "results":{"count_id":2,                   "count_type":"clutch",                   "count_date":"2000-01-01",                   "fish_count":250,                   "count_notes":"test"}       };  var arr= dosomething(j.results); //arr=[2, "clutch","2000-01-01",250,"test"] 

your function like

var dosomething = function (obj) {     var arr = [];     (var x in obj) if (obj.hasownproperty(x)) {         arr.push(obj[x]);     }     return arr; } 

Comments