This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Extracting Values from JSON data - Amber Electric API
#3
Hi Erwin,

The last value of the variablePricesAndRenewables subset isn't always the value we require - we need the period for the half hour increment which is the last one tagged as periodType":"ACTUAL"

.. this will change depending on the time of day.  The variablePricesAndRenewables subset contains half hour increments for the day.  The point where the tags change from ACTUAL to FORECAST changes based on the time of day that we pull the data.

Is there a way to scan the JSON data values within the variablePricesAndRenewables subset to find the last one tagged with periodType":"ACTUAL" rather than the last one in the subset?

Kind Regards
James

Hi,

Further to my last message I've added the following code to return the last period of type ACTUAL


Code:
for i,k in ipairs(mydata.data.variablePricesAndRenewables) do
      if (k.periodType == 'ACTUAL') then
        wholesaleKWHPrice = k.wholesaleKWHPrice
      end
    end

Thanks for your help
Reply


Messages In This Thread
RE: Extracting Values from JSON data - Amber Electric API - by jamesng - 27.12.2020, 13:22

Forum Jump: