In my sample json below, I can filter records where charge is null with jq -M ' map(select(.charge == null)) '
[
{
"id": 1,
"name": "vehicleA",
"state": "available",
"charge": 100
},
{
"id": 2,
"name": "vehicleB",
"state": "available",
},
{
"id": 3,
"name": "vehicleB",
"state": "available",
"charge": 50
}
]
which returns:
{
"id": 2,
"name": "vehicleB",
"state": "available",
}
How would one only get id and the value associated with id of the filtered records so that adding this step to the above query would return 2?