将JSON对象属性提取到数组中的简单方法?

dna*_*irl 4 javascript json

给定以下JSON对象,是否有一种简单的方法可以仅提取results对象属性的值?

var j={"success":true,
       "msg":["Clutch successfully 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"]
Run Code Online (Sandbox Code Playgroud)

Rob*_*ert 5

您的功能将类似于

var doSomething = function (obj) {
    var arr = [];
    for (var x in obj) if (obj.hasOwnProperty(x)) {
        arr.push(obj[x]);
    }
    return arr;
}
Run Code Online (Sandbox Code Playgroud)