Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1652
  • Last Modified:

Loop over deserialized json

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
kabookis
Asked:
kabookis
  • 2
1 Solution
 
_agx_Commented:
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
 
kabookisAuthor Commented:
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
 
_agx_Commented:
Haha, you're welcome ... and that's a great line closing line :)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now