更新时间:2023-01-08 12:11:18
您可以创建一个返回所需数组的函数:
然后,您可以映射并在JSON中的属性上调用它:
You could make a function that returns the array you want: You could then map through and call this on the properties in your JSON:
function makeArray(value) {
return j.map(function(a) {
return {[value]: a[value]};
});
}
var labels = makeArray('label');