Handling Arrays (JSON files)

Hi,
I’m very new to Home Assistant, I’m trying to use the JSON file returned from an Octopus energy rest pull for both pricing and consumption and exports.
I know I can only normally get these a day after I’ve used them but I’d like to create a dashboard that can show electricity costs for the day/week/month and then roll up to the year.
I know that in PowerShell I could just use a foreach loop to cycle through the elements in the Results section but I’m not sure how I’d do the following in HA:

  1. loop through the json elements and select the “valid_from” and “value_inc_vat” elements from each.
  2. as above but loop through the elements of the usage JSON file and then for out the 1/2 hourly price
  3. Do the same but for exports.
  4. store these variables long term.
  5. create a dynamic tile on a dash board

Once I get a grip on the coding language I’m normally alright with things but any help, etc, would be greatly received.
The structure of the JSON is:

Hello.

Keep in mind images of text is pretty much useless. There is no reason what so ever to not post the text as text.

But to decode a json you use a restful sensor.

Sorry, I didn’t want to post the json file in case it broke any rules, etc.
I’ve read through the Restful sensor page and, correct me if I’m wrong, I’d use the josn_attributes line to pull out the 2 lines I want for the “valid_from” and “value_inc_vat”
I get that part, the part I don’t understand, am it’s probably me over thinking it, how would I cycle through all the results in the JSON?

I’m not sure what you are trying to do so I can’t help because of that.
But looking at the template tools there is an example how to loop a jsonstructure.

For loop example getting entity values in the weather domain:

{% for state in states.weather -%}
  {%- if loop.first %}The {% elif loop.last %} and the {% else %}, the {% endif -%}
  {{ state.name | lower }} is {{state.state_with_unit}}
{%- endfor %}.

So what you need to do is to change the entities

value_template: >-
          {% for index in value_json["results"] -%}
            {{ index.value_exe_vat }}
          {%- endfor %}.

That’s about what I understand that you want to do.

Thank you both for your posts, I think I understand it now.