?
Solved

Loop over deserialized json

Posted on 2013-10-28
3
Medium Priority
?
1,526 Views
Last Modified: 2013-10-28
When I deserialize this:
{ "json_list": [ { "descr": "Rectangle Cold Finish LBS", "prodline": "0FC", "shape": "BAR", "sig": "ALFC" }, { "descr": "Aluminum Bar LBS", "prodline": "0FE", "shape": "BAR", "sig": "ALFE" } ] }

<cfset cfData = DeserializeJSON(theData)>

I get (I think) a struct (json_list"), and an array of structs with two structs. I need to extract the values for "prodline". How can this be accomplished?
0
Comment
Question by:kabookis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 39607583
Yes, it's an array of structures. Just loop through the array and extract the "prodline" key within the array:

<cfset cfData = DeserializeJSON(theData)>
<cfset dataArray = cfData.json_list>

<cfloop array="#dataArray#" index="elem">
      <!--- print out value for demo purposes --->
      <cfoutput>
       prodline value = #elem.prodline#  <br>
      </cfoutput>
</cfloop>
0
 

Author Closing Comment

by:kabookis
ID: 39607591
What is the record for the fastest correct response? This one has got to be up there.
I've waited longer in line at Mcdonald's.
Thanks for the help.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39607596
Haha, you're welcome ... and that's a great line closing line :)
0

Featured Post

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question