Copy link to clipboard
Copied
I am a bit lost on how to get the data out of a structure created from deserializeJSON. I am trying for example to set Results = data / array1 / doc / m.
So along the lines of <cfset results = #data.doc.m[1]#> but that's not right... What's the proper way to do this?
When I dump the results the look like:
It's been a while since I've worked with JSON, but try: data[1].doc.m
V/r,
^ _ ^
Copy link to clipboard
Copied
It's been a while since I've worked with JSON, but try: data[1].doc.m
V/r,
^ _ ^
Copy link to clipboard
Copied
Thanks! That did it.
Copy link to clipboard
Copied
Awesome! Glad I could actually remember that. And glad that you got it working.
And thank you for marking my answer as correct. I do appreciate it.
V/r,
^ _ ^
Copy link to clipboard
Copied
Oh, and
<cfset results = data[1].doc.m>
is better syntax than
<cfset results = #data[1].doc.m#>
Copy link to clipboard
Copied
Oh, yeah! I totally slipped on that one, BKBK. Glossed right over it.
ghanna1​, I used to have links to articles about how using hashtags around variables, etc, when not outputting to the screen or within quotes to set variables can actually slow things down. So, as BKBK points out, the #data[1].doc.m# in setting the results variable should be without the hashtags.
V/r,
^ _ ^
Copy link to clipboard
Copied
I knew not to use the # but this is good information for the next person reading this trail.
Thanks!