I am looping over an array of structures and trying to assign and store all key values. If I wrap inner loop in <cfoutput>, I am getting an error: "Complex object types cannot be converted to simple values". If I leave it out, then it does not work. What am I missing?
<cfif isJSON(httpResp.fileContent)>
<cfset jsonData = deserializeJSON(httpResp.fileContent) />
<cfloop from="1" to="#arrayLen(jsonData)#" index="i">
<cfset data = jsonData[i]>
<!---<cfoutput>--->
<cfloop collection="#data#" item="key">
#key#:#data[key]#<br>
</cfloop>
<!---</cfoutput>--->
</cfloop>
<cfdump var="#jsonData#">
<cfelse>
Did not receive a valid Json object
</cfif>
Here is the output:
#key#:#data[key]#
#key#:#data[key]#
#key#:#data[key]#
#key#:#data[key]#
#key#:#data[key]#
#key#:#data[key]#
#key#:#data[key]#
#key#:#data[key]#
#key#:#data[key]#
#key#:#data[key]#

cfoutput- can be difficult when the data is not the same length each time. With structs like that you'll maybe want to useStructFindKey(). If you expect similar data structure each time it should be easy enough to write conditional logic inside your loop.