I have the following json file which this value
{
"data": [
{
"id": 60573936,
"timeCreated": 1615458564202,
"timeUpdated": 1615458564202,
"name": "name1",
"desiredStatus": "UNMANAGED",
"defaultStatus": "STARTED",
"targets": [
{
"id": 2520949,
"lastReportedStatus": "STOPPED"
}, {
"id": 702881,
"lastReportedStatus": "STARTED"
}
]
}, {
"id": 60574370,
"timeCreated": 1615458812565,
"timeUpdated": 1615458812565,
"name": "name2",
"desiredStatus": "UNMANAGED",
"defaultStatus": "STARTED",
"targets": [
{
"id": 2520949,
"lastReportedStatus": "STARTED"
}, {
"id": 702881,
"lastReportedStatus": "STOPPED"
}
]
}, {
"id": 60574329,
"timeCreated": 1615458775053,
"timeUpdated": 1615458775053,
"name": "name3",
"desiredStatus": "UNMANAGED",
"defaultStatus": "STARTED",
"targets": [
{
"id": 2520949,
"lastReportedStatus": "STOPPED"
}, {
"id": 702881,
"lastReportedStatus": "STARTED"
}
]
}
]
}
I would like to extract the "name" value only if "id"="2520949" and "lastReportedStatus"="STOPPED" using jq. In my example I would like to get "name1" and "name3". I tried using select feature but I'm not able to satisfy the "and" condition between "id" and "lastReportedStatus" key. What is the correct code with jq ?