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

Get data from deserializeJSON

Contributor ,
Jul 16, 2019 Jul 16, 2019

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

812
Translate
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,

^ _ ^

Translate
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,

^ _ ^

Translate
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

Thanks!  That did it.

Translate
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

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,

^ _ ^

Translate
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

Oh, and

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

is better syntax than 

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

Translate
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

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,

^ _ ^

Translate
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
LATEST

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

Thanks!

Translate
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