Учитывая, что у меня есть следующее json:
{
"id": "images",
"type": "collection",
"href": "https://api.ionos.com/cloudapi/v5/images",
"items": [
{
"id": "2bdfc61e-1ff7-11ea-af1c-525400f64d8d",
"type": "image",
"href": "https://api.ionos.com/cloudapi/v5/images/2bdfc61e-1ff7-11ea-af1c-525400f64d8d",
"metadata": {
"etag": "b1a133b9ac038de9157572bbc3491898",
"createdDate": "2019-12-16T11:28:24Z",
"createdBy": "System",
"createdByUserId": "System",
"lastModifiedDate": "2019-12-16T11:28:24Z",
"lastModifiedBy": "System",
"lastModifiedByUserId": "System",
"state": "AVAILABLE"
},
"properties": {
"name": "windows-2008-r2-server-2019-12",
"description": "",
"location": "gb/lhr",
"size": 18,
"cpuHotPlug": true,
"cpuHotUnplug": false,
"ramHotPlug": false,
"ramHotUnplug": false,
"nicHotPlug": true,
"nicHotUnplug": true,
"discVirtioHotPlug": true,
"discVirtioHotUnplug": false,
"discScsiHotPlug": false,
"discScsiHotUnplug": false,
"licenceType": "WINDOWS",
"imageType": "HDD",
"imageAliases": [
"windows:2008r2"
],
"public": true
}
},
{
"id": "d65c184b-cd78-11e9-b88c-525400f64d8d",
"type": "image",
"href": "https://api.ionos.com/cloudapi/v5/images/d65c184b-cd78-11e9-b88c-525400f64d8d",
"metadata": {
"etag": "f3f490ba129dbb56b4dd0f97870240b8",
"createdDate": "2019-09-02T11:57:28Z",
"createdBy": "System",
"createdByUserId": "System",
"lastModifiedDate": "2019-09-02T11:57:28Z",
"lastModifiedBy": "System",
"lastModifiedByUserId": "System",
"state": "AVAILABLE"
},
"properties": {
"name": "ubuntu-16.04.6-server-amd64.iso",
"description": "",
"location": "gb/lhr",
"size": 0.86,
"cpuHotPlug": true,
"cpuHotUnplug": false,
"ramHotPlug": true,
"ramHotUnplug": false,
"nicHotPlug": true,
"nicHotUnplug": true,
"discVirtioHotPlug": true,
"discVirtioHotUnplug": true,
"discScsiHotPlug": false,
"discScsiHotUnplug": false,
"licenceType": "LINUX",
"imageType": "HDD",
"imageAliases": [
"ubuntu:16.04_iso"
],
"public": true
}
},
]
}
Мне нужно найти первый id
среди items
, который имеет properties
, имеет "licenceType": "LINUX"
и "imageType": "HDD"
.
Вот код, который я пробовал:
$.items[?(@.properties.imageType=="HDD"
@.properties.licenceType=="LINUX" )].id
В моем примере он должен вернуть d65c184b-cd78-11e9-b88c-525400f64d8d
Но это не дает мне ничего.