Solved

Loop over deserialized json

Posted on 2013-10-28
3
1,288 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
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
Comment Utility
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
Comment Utility
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_
Comment Utility
Haha, you're welcome ... and that's a great line closing line :)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now