Need help parsing the below nested Json. The end goal is to get the quota limits
from GCP that have non-default values. Below is the sample data for one of the services (compute APIs for a given CPU type)
I am struggling to be able to compare
I came up with the below but it doesn't work and returns an error
.[]|select (.quota[].defaultLimit|tonumber != .quota[].effectiveLimit|tonumber)
[
{
"metric": "compute.googleapis.com/a2_cpus",
"quota": [
{
"defaultLimit": "-1",
"effectiveLimit": "-1"
}
]
},
{
"metric": "compute.googleapis.com/a2_cpus",
"quota": [
{
"defaultLimit": "12",
"effectiveLimit": "12"
},
{
"defaultLimit": "12",
"dimensions": {
"region": "asia-east1"
},
"effectiveLimit": "13",
"producerOverride": {
"dimensions": {
"region": "asia-east1"
}
}
}
]
}
]
the expected output would be something like this
[
{
"metric": "compute.googleapis.com/a2_cpus",
"quota": [
{
"defaultLimit": "12",
"dimensions": {
"region": "asia-east1"
},
"effectiveLimit": "13"
}
]
}
]
Any help is appreciated.