0
我有以下JSON响应:如何映射嵌套对象数组?
{
"fruits": [
{
"name": "apple",
"prices": [
{
"small": 2,
"medium": 3,
"large": 5
}
]
},
{
"name": "banana",
"prices": [
{
"small": 1,
"medium": 3,
"large": 4
}
]
}
]
}
我想把它映射到一个新的数组,这样我就可以得到每个水果的“price.small”:
$scope.new_data = $scope.fruits.map(function(fruit){
return {
name: fruit.name,
price_small: fruit.prices.small
};
});
但它的不工作