Created
November 6, 2019 14:36
-
-
Save trycf/09267cda2ed6cef3c9f637327ce8eae7 to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 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