Solved

Loop over deserialized json

Posted on 2013-10-28
3
1,444 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 500 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

732 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