Search code examples
arrayscoldfusioncoldfusion-2016

Cannot loop simple array


I have done this many time before but I'm not sure what is wrong with my code. I just need to loop this simple array:

enter image description here

Here is my code:

<cfoutput>
    <cfset myData = deserializeJSON(getHttpRequestData().content) />

<cfdump var="#myData#" />
  <cfloop from="1" to="#ArrayLen(myData)#" index="i">
   Type #i#: #myData[i]#<br>
  </cfloop>
</cfoutput>

But I'm getting this error: enter image description here

Why can't I access the array with index key. Please somebody help me? Thanks in advance.


Solution

  • Variable myData appears to be an array of structures. That means myData[i] is a structure, and you can't simply output it.

    You have to do something else. What that something else is depends on your overall objective.