I am trying to get carbon intensity and generation mix from this API: https://api.carbonintensity.org.uk/regional/regionid/6 using the HTTP binding.
My thing has a channel:
Type number : Intensity [ stateTransformation="JSONPATH:$.data[0].data[0].intensity.forecast", mode="READONLY"]
which works perfectly.
I am now trying to query the JSON array for the percentage of generation by each fuel.
Using $.data[0].data[.generationmix[?(@.fuel == 'gas')].perc
in https://jsonpath.com/, I get the correct answer, but in OpenHAB, I get the whole JSON string back. This is expected behaviour if there are no matches.
To try to diagnose the problem, I have shrunk the expression to: $.data[0].data[0].generationmix
; In the parser, I get the array of percentage by fuel type but in OpenHAB, I still get the whole string, indicating no match.
Two questions:
- Is there an online JSON parser that can reliably be used to test expressions prior to using them in OpenHAB?
- Any pointers as to where my expressions are wrong?
Thanks