Here is my JSON :
[
{
"Data": [
{
"Count": null,
"TimeStamp": "2023-03-18T09:56:00Z",
"Average": null,
"Maximum": 0.4,
"Minimum": null,
"Total": null
}
],
"Name": {
"LocalizedValue": "DTU used",
"Value": "dtu_used"
},
"Unit": "Count"
},
{
"Data": [
{
"Count": null,
"TimeStamp": "2023-03-18T09:56:00Z",
"Average": null,
"Maximum": 20.0,
"Minimum": null,
"Total": null
}
],
"Name": {
"LocalizedValue": "DTU Limit",
"Value": "dtu_limit"
},
"Unit": "Count"
}
]
I am trying to get the value of Data.*.Maximum in the same array where Name.Value = 'dtu_limit'.
I can get the values of Maximum with $.*.Data.*.Maximum
but I don't know how to filter.
I tried things like this but that doesn't work : $.*[?(@.Name.Value == 'dtu_used')].Data.*.Maximum
Please help !
...doesn't work :
$.*[?(@.Name.Value == 'dtu_used')].Data.*.Maximum
You need to remove that first .*
. So either:
$[?(@.Name.Value == 'dtu_used')].Data.*.Maximum
or
$[?(@.Name.Value == 'dtu_limit')].Data.*.Maximum
Depending on which value you want to filter by.