我正在使用JQGRId来获取JSON对象格式的网格数据。
结果是这样的:
{"Key":"value1"},{"Key":"value2", "id":"id"}
我需要将所有值放入“键”的数组中。
var arr = [{"Key":"value1"},{"Key":"value2", "id":"id"}];
var anArrayOfKeyValues = [];
arr.forEach(function(ob, i) {
if("Key" in ob) anArrayOfKeyValues.push(ob.Key);
});
console.log(anArrayOfKeyValues); // ["value1", "value2"]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句