Is create a dynamically sized template array possible for a template sensor?

I’m attempting to create a RESTful template sensor, the data returned is too long to just stuff into the state, so I am attempting to just pick out the information I want and store an array in the state.

For example the json returned (dummy data) would look something like…

{ "data": [
     {"record":"1","x":"1","y":"2","z":"3"},
     {"record":"2","x":"4","y":"5","z":"6"},
     {"record":"3","x":"7","y":"8","z":"9"}
     ...
     {"record":"n","x":"7","y":"8","z":"9"}
   ]
}

This array returned from the REST call could have 0, 1, 2, 3, … 100, …1000 records in it. So I’d like to create my array in my sensor dynamically, not just hard code it to a couple records.

For testing purposes so you don’t have to modify the above array…

{ "data": [
     {"record":"1","x":"1","y":"2","z":"3"},
     {"record":"2","x":"4","y":"5","z":"6"},
     {"record":"3","x":"7","y":"8","z":"9"}
   ]
}

I’d like to create a sensor using a template that would end up looking like this…

[
  {"record":"1","x":"1","y":"2"},
  {"record":"2","x":"4","y":"5"},
  {"record":"3","x":"7","y":"8"},
]

I have no issue creating the for loop in the template, I just can’t figure out how to append a new item in the list dynamically.

Just FYI: attributes do not have the 255 character limit.