我只想从下面的对象中提取产品名称、产品 ID、SKU
{
"Product Name": "Bowler Hat",
"ProductID": 858383,
"SKU": "0406654608",
"Description": {
"Colour": "Purple",
"Width": 300,
"Height": 200,
"Depth": 210,
"Weight": 0.75
},
"Price": 34.45,
"Quantity": 2
}
预期结果:
{
"Product Name": "Bowler Hat",
"ProductID": 858383,
"SKU": "0406654608"
}
尝试过的解决方案:
直接对象映射:
{ "Product Name": `Product Name`, "ProductID": ProductID, "SKU": SKU }
筛:
$sift(function($v, $k) {$k ~> /^Product Name|ProductID|SKU/})
需要一种更简单的方法来做到这一点。就像是:
{ `Product Name`, ProductID, SKU}