I have a struct that’s inside an array that is nested inside another struct, like so: Arguments.cart.data.Items[x].Labels.Pkg.Title (x is an index, as I’m looping over Items).
Items is an array while Labels, Pkg, and Title are nested structs.
Title does not always exist. So I would like to check for it. However, using structFindKey returns an error
You have attempted to dereference a scalar variable of type class coldfusion.runtime.Array as a structure with members
I could just look inside Arguments.cart.data; however, if there are multiple rows in the array, some rows may contain Title while others do not. So I want to check for Title inside each Items.
I’ve also tried arrayFind, but then I get the error
Struct cannot be used as an array
I’m at a loss here.
This will do the job
IsDefined doesn’t play nicely with arrays, but by assigning each element of the array to the temp value you are then able to refer to it within IsDefined.
Alternatively you can do the following, if you prefer StructKeyExists