Extracting json body

I have problems getting the information out of a json body.
I tried jsonpath evaluator. The input i have is;
{“energyDetails”:{“timeUnit”:“YEAR”,“unit”:“Wh”,“meters”:[{“type”:“Production”,“values”:[{“date”:“2020-01-01 00:00:00”,“value”:2189424.0}]}]}}

I want out of value the number 2189424.0

the solution from jsonpath is: $.energyDetails.meters.[value]

when i try this in homeyscript it doesn’t work;
var body = await res.json();
var body2 = body.energyDetails.meters.values[‘value’]


var body2 = body.energyDetails.meters.[‘value’]

the console gives as result; Undefined

Anyone a idea how to get the correct format?


1 Like

Great, works💪