本文介绍了如何获取特定键的JSON对象值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用JQGRId来获取JSON对象格式的网格数据.
I am using JQGRId to get the grid data in JSON object format.
结果类似于:
{"Key":"value1"},{"Key":"value2", "id":"id"}我需要将所有值放入键"的数组中.
I need to get all the values into an array for "key".
推荐答案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"]
更多推荐
如何获取特定键的JSON对象值
发布评论