Pulling Out Struct Variables

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!

Could you try with this simple & static example,


<cfscript>
    arr = [];
    arr[1] = {"position":"prof","category":
    {"id":"1","name":"jhon"},"age":23};
    dump(arr);
    categoryname = arr[1].category.name;
    categoryid = arr[1].category.id;
    arr[1].category.name = "joe";
    dump(arr);
    dump(categoryname);
    dump(categoryid);
</cfscript>
1 Like

Cool! Thanks.

Seeing how you did that, I actually ended up using the following:

<cfset CategoryID   =i.category.id>
<cfset CategoryName =i.category.name>

Since my CFLOOP over this array is:

<cfloop array="#deserialized#" index="i">
1 Like