我将如下所示的数组作为对象的属性之一。我想提取某些字段并将其仍作为数组返回到输出中。例如,我只希望像下面的
那样返回name
和storageAccountType
所需的输出
[
{
"name": "Data",
"storageAccountType": "Standard_LRS"
},
{
"name": "Disk2",
"storageAccountType": "Standard_LRS"
}
]
输入数组
[
{
"name": "Data",
"createOption": "Attach",
"diskSizeGB": 10,
"managedDisk": {
"id": "/subscriptions/24ba3e4c-45e3-4d55-8132-6731cf25547f/resourceGroups/GREG/providers/Microsoft.Compute/disks/Data",
"storageAccountType": "Standard_LRS"
},
"caching": "None",
"toBeDetached": false,
"lun": 0
},
{
"name": "Disk2",
"createOption": "Attach",
"diskSizeGB": 10,
"managedDisk": {
"id": "/subscriptions/24ba3e4c-45e3-4d55-8132-6731cf25547f/resourceGroups/GREG/providers/Microsoft.Compute/disks/Disk2",
"storageAccountType": "Standard_LRS"
},
"caching": "None",
"toBeDetached": false,
"lun": 1
}
]
答案 0 :(得分:0)
这是您可以遵循的指示(假设您实际上需要取回数组,而不要将数组中的每个元素都放在自己的行中。如果后者不错,请删除带有注释的行({{1} })
// *