[Solved] Help with JSONs
Let’s say I have 2 JSONs stored in 2 variables: “price_schedule“ that carries energy prices for a couple of days, and “current_timeslot“ that tells me what is the current date and time.
“current_timeslot” looks like this:
{
"from": "2023-11-14T12:00:00+01:00",
"to": "2023-11-14T13:00:00+01:00",
}
and “price_schedule“ looks like this:
{
"prices": [
{
"from": "2023-11-13T00:00:00+01:00",
"to": "2023-11-13T01:00:00+01:00",
"value": 102
},
{
"from": "2023-11-13T01:00:00+01:00",
"to": "2023-11-13T02:00:00+01:00",
"value": 99
},
...
{
"from": "2023-11-14T23:00:00+01:00",
"to": "2023-11-15T00:00:00+01:00",
"value": 98
}
]
}…in which I can successfully parseJson(price_schedule,"prices.0.value") where 0 is the location in the json array.
Now i have a bar chart in ProtoPie i want to show these data:
How can I search inside the “price_schedule” and return me the “value” for the time slot that is reported by the “current_timeslot”?
How can I get the “value” for the next 6 hours ahead and 3 hours before?
I understand all I need is basically knowing the location of the current timeslot in the json array e.g. 22. I have seen JSON work by @John Redhead but I couldn’t reproduce it to work in my case. Any help will be highly appreciated!