I’m trying to extract a value from this JSON using ‘transform’ in a rule.
{
"request": {
"station": "1448",
"date_from": "2020-01-18",
"date_to": "2020-01-18",
"time_from": "19:00:00",
"time_to": "19:00:00",
"lang": "de",
"index": "code",
"datetime_from": "2020-01-18 18:00:00",
"datetime_to": "2020-01-18 18:00:00"
},
"data": {
"1448": {
"2020-01-18 18:00:00": [
"2020-01-18 19:00:00",
2,
1,
[
5,
45,
2,
"2.068"
]
]
}
},
"indices": {
"data": {
"station id": {
"date start (CET)": [
"date end (CET)"
],
"date start": {
"1": "total index",
"2": "data incomplete",
"3": [
"component id",
"value",
"index",
"y-value"
]
}
}
}
},
"count": 1
}
The specific value that I’m looking for is “45”. When I analyze the JSON using “jsonpath online evaluator”, the following syntax
$.data.1448.2020-01-18 18:00:00.3.1
delivers the right result:
[
45
]
Using this same expression in a rule
val newValue = transform("JSONPATH", "$.data.1448.2020-01-18 18:00:00.3.1", NOX_JSON.state.toString)
with NOX_JSON being the JSON expression above, I get “NULL” as a result.
What is wrong with my way of using “transform”?