• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Get data from deserializeJSON

Contributor ,
Jul 16, 2019 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

Views

598

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
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 17, 2019 Jul 17, 2019

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

V/r,

^ _ ^

Votes

Translate

Translate
LEGEND ,
Jul 17, 2019 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,

^ _ ^

Votes

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
community guidelines
Contributor ,
Jul 17, 2019 Jul 17, 2019

Copy link to clipboard

Copied

Thanks!  That did it.

Votes

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
community guidelines
LEGEND ,
Jul 17, 2019 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,

^ _ ^

Votes

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
community guidelines
Community Expert ,
Jul 17, 2019 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#>

Votes

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
community guidelines
LEGEND ,
Jul 17, 2019 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,

^ _ ^

Votes

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
community guidelines
Contributor ,
Jul 17, 2019 Jul 17, 2019

Copy link to clipboard

Copied

LATEST

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

Thanks!

Votes

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
community guidelines
Resources
Documentation