i need an advice, i have a structure data returned...
# cfml-general
g
i need an advice, i have a structure data returned from api and i have a list of few names, i am trying to loop over a structure and see if one ofg structure key,name matches one in list, it should add another structure to it with the value of the item which was found, i am trying something like this an incomplete gist https://trycf.com/gist/5dcdbd480d582a318144288e89a078d6/lucee5?theme=monokai
m
I don't think there's enough in your gist to get any hint of a gist of what you're trying to do. What exactly are you confused about?
g
i have a data coming back to me as array of structs, and i am trying to compare the values in list with the data being returned and if there is a match, i am injecting that value into the struct with a new kery
s
still not clear enough. Perhaps you can add a sample of the array of structs to your trycf example? and give an example of the output you are trying to acheive
👍 1
m
The gist you posted doesn't have any of that. You should include the struct you're receiving and/or whatever
getLibraries
is. But I don't see any comparing or injecting. Additionally,
structFind()
doesn't return a boolean.
g
umm, let me update the data i am getting
this is the updated and along with what i am seeking as an answer
b
getLibraries.each( (lib) => lib.exists = lst.findNoCase( lib.name & ".js" ) > 0 ? lib.name & ".js" : "" ) dump(getLIbraries)
m
@gsr, have you tried running the code in your gist?
getLibraries
is an array, not a struct, so you can't loop over it as a
collection
.
g
@bhartsfield Nice, such a clean code
but very unfortunate, cf2021 does not recognize
s
probably just need to change that dump line to:
writedump(getLibraries);
for it to work in acf 2021
👍 1