US State Choropleth Via JSON

I’ve been looking over the USA Choropleth example, but I’m unsure how to do it with a JSON object in my script that’s updating via API requests when the page loads.

I currently have all 50 states indexed alphabetically within an object. Each state is an object that contains the X-Y values I’m looking to plot as arrays. These arrays are filled with API data triggered by the page load.

What is the best way to ensure the corresponding values match with the state?

Do I basically just need to have an array under “locations:” that matches with an array under “z:”?

Thanks so much!