Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trycf/09267cda2ed6cef3c9f637327ce8eae7 to your computer and use it in GitHub Desktop.
Save trycf/09267cda2ed6cef3c9f637327ce8eae7 to your computer and use it in GitHub Desktop.
TryCF Gist
<!--- sample json --->
<cfset jsonString = '{"categories":[{"path":"/root","subCategories":[{"id":"1","name":"sub category A"}],"id":"2"},{"path":"/root/parent","subCategories":[{"id":"1","name":"sub category B"}],"id":"3"}]}'>
<!--- convert to cf objects --->
<cfset sample = deserializeJSON( jsonString )>
<!--- array loop --->
<cfloop array="#sample.categories#" index="category">
<cfoutput>
<h4>(category.id) #category.id#</h4>
<cfloop array="#category.subCategories#" index="subcategory">
<li>(subcategory.name) #subcategory.name#</li>
</cfloop>
</cfoutput>
</cfloop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment