我有一些JSON和想回一些嵌套的对象,这是JSON:如何返回嵌套数组与lodash?
{
"existingPackage": {
"primaryBundle": {
"id": "2031",
"serviceId": "114297251",
"name": "TV - Entertainment, Drama, Movies",
"products": [
{
"name": "Entertainment",
"id": "100",
"price": 2600,
"gifted": false
},
{
"name": "Drama",
"id": "104",
"price": 2000,
"gifted": false,
"swappableProducts": [
{
"name": "Sport",
"id": "107",
"price": 2500,
"gifted": false
}
]
},
{
"name": "Movies",
"id": "105",
"price": 2000,
"gifted": false,
"swappableProducts": [
{
"name": "Sport",
"id": "107",
"price": 2500,
"gifted": false
}
]
}
]
}
}
}
的目标是从有swappableProducts财产,并有一定的id productsarray返回唯一项目。 因此,例如,当我的productId参数= 105,然后我想回:
{
"name": "Movies",
"id": "105",
"price": 2000,
"gifted": false,
"swappableProducts": [
{
"name": "Sport",
"id": "107",
"price": 2500,
"gifted": false
}
]
}
}
如何我lodash返回此?
可能重复的[如何使用lodash从数组中找到并返回一个对象?](http://stackoverflow.com/questions/31054021/how-to-use-lodash-to-find-and-return-一个对象-从阵列) – Rajesh