I need help with the following. I have the below json response and I'm trying to sum all the "value" objects in a jinja template. I have no ideea how to deal with json data in jinja templates. Can anyone point me in the right direction? Thanks a bunch!
{
"body": [
{
"beg_time": 1689172769,
"step_time": 3600,
"value": [
[3],
[2.2],
[1.2]
]
},
{
"beg_time": 1689187169,
"step_time": 3600,
"value": [
[0],
[0],
[0],
[2.02],
[2.6],
[0],
[0]
]
},
{
"beg_time": 1689215969,
"step_time": 3600,
"value": [
[0],
[2.1],
[0],
[1.4],
[0],
[0],
[0],
]
}
],
"status": "ok",
"time_exec": 0.03644895553588867,
"time_server": 1689257978
}
This is as close as I've gotten but the json response varies in length (sometimes is 2 arrays, sometimes is 3) and I get "UndefinedError: list object has no element 2"
{{ value_json2.body.0.value | sum(attribute=0) | round(1) }} + {{ value_json2.body.1.value | sum(attribute=0) | round(1) }} + {{ value_json2.body.2.value | sum(attribute=0) | round(1) }}