【发布时间】:2017-07-13 15:23:16
【问题描述】:
我有以下 JSON,我想提取唯一的位置并将其放入另一个 JSON 或数组中,格式与以前相同。我是新手,所以有点困惑。
这就是我所拥有的:
let data = {
"Person" : [{"name":"harman","comment_count":255},
{"name":"aman","comment_count":66},
{"name":"mukesh","comment_count":66}],
"location": [{"name":"delhi","comment_count":255},
{"name":"mumbai","comment_count":66},
{"name":"chandigarh","comment_count":66}],
"org ": [{"name":"dell","comment_count":255},
{"name":"apple","comment_count":66},
{"name":"hp","comment_count":66}],
"teams" : [{"name":"Real","comment_count":255},
{"name":"Juve","comment_count":66},
{"name":"Liverpool","comment_count":66}]
};
这就是我想要的:
data2 = {
"location": [
{"name":"delhi","comment_count":255},
{"name":"mumbai","comment_count":66},
{"name":"chandigarh","comment_count":66}]
};
【问题讨论】:
-
data2.location = data.location;
标签: javascript html angularjs arrays json