I have been trying for days to breakdown a JSON array and it's values. But after countless posts and sites, I still cannot get it properly displayed.
If you look at this feed: https://api.weather.gov/alerts/active?zone=TXC005
You will see there are coordinates in the array. I have been able to get the other values, but the sub arrays are proving to be quite a problem. I'm sure it has to be something very simple.
Here is my code where I loop through:
<cfloop from="1" to="#ArrayLen(myArrayObj)#" index="i">
<cfoutput>
<strong>NOAA Feed:</strong> #myArrayObj[i].properties.event#<br></strong>
Effective: #myArrayObj[i].properties.effective#<br>
Headline: #myArrayObj[i].properties.headline#<br>
Area: #myArrayObj[i].properties.areaDesc#<br>
Type: #myArrayObj[i].properties.messageType#<br>
Description: #myArrayObj[i].properties.description#<br>
<cfloop from="1" to="#ArrayLen(myArrayObj[i].geometry.coordinates)#" index="g">
#myArrayObj[i].geometry.coordinates[g]#
</cfloop>
<cfloop from="1" to="#ArrayLen(myArrayObj[i].properties.geocode.same)#" index="j">
#myArrayObj[i].properties.geocode.same[j]#<br>
</cfloop>
</cfoutput>
<hr>
</cfloop>
You'll see this section is where it is breaking trying to display the coordinates:
<cfloop from="1" to="#ArrayLen(myArrayObj[i].geometry.coordinates)#" index="g">
#myArrayObj[i].geometry.coordinates[g]#
</cfloop>
I know what I am missing is super simple.... but I'm just going crazy trying to figure it out. Any help would be greatly appreciated!
When looking at the api object, the coordinate values are in arrays of an array of an array. Referencing those values would look like: coordinates[1][1][1],coordinates[1][1][2],etc.