Highlighted

Get data from deserializeJSON

Participant ,
Jul 16, 2019

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:

Screen Shot 2019-07-16 at 10.43.12 PM.png

It's been a while since I've worked with JSON, but try:  data[1].doc.m

V/r,

^ _ ^

Views

372

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Get data from deserializeJSON

Participant ,
Jul 16, 2019

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:

Screen Shot 2019-07-16 at 10.43.12 PM.png

It's been a while since I've worked with JSON, but try:  data[1].doc.m

V/r,

^ _ ^

Views

373

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 16, 2019 0
LEGEND ,
Jul 17, 2019

Copy link to clipboard

Copied

It's been a while since I've worked with JSON, but try:  data[1].doc.m

V/r,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 17, 2019 0
Participant ,
Jul 17, 2019

Copy link to clipboard

Copied

Thanks!  That did it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 17, 2019 0
LEGEND ,
Jul 17, 2019

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,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 17, 2019 0
Adobe Community Professional ,
Jul 17, 2019

Copy link to clipboard

Copied

Oh, and

<cfset results = data[1].doc.m>

is better syntax than 

<cfset results = #data[1].doc.m#>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 17, 2019 0
LEGEND ,
Jul 17, 2019

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,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 17, 2019 0
ghanna1 LATEST
Participant ,
Jul 17, 2019

Copy link to clipboard

Copied

I knew not to use the # but this is good information for the next person reading this trail.

Thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 17, 2019 1