Copy link to clipboard
Copied
Newbie question hereā¦ how do I get / set these values in this (sub)Struct to variables?
In the end, I want to have them set to variables like:
<cfset CategoryID = StructVar>
<cfset CategoryName = StructVar>
Thanks!
Copy link to clipboard
Copied
Actually ended up figuring this one out.
I used:
<cfset CategoryID =i.category.id>
<cfset CategoryName =i.category.name>
Since my CFLOOP over this array is:
<cfloop array="#deserialized#" index=āiā>
Copy link to clipboard
Copied
I was going to say that it depends upon what you named the struct, but you did, indeed, figure it out.
V/r,
^ _ ^
Copy link to clipboard
Copied
MrLeG8 wrote
Actually ended up figuring this one out.
<cfset CategoryID =i.category.id>
<cfset CategoryName =i.category.name>
This is correct, but has the disadvantage that you overwrite the values of categoryID and categoryName at every iteration of the loop. If you wanted a more reusable solution, you could do something like
<cfset categoryID=arrayNew(1)>
<cfset categoryName=arrayNew(1)>
<cfloop from="1" to="#arrayLen(deserialized)#" index="n">
<cfset categoryID
<cfset categoryName
</cfloop>
<!--- verify --->
<cfdump var="#categoryID#" >
<cfdump var="#categoryName#" >