Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a JSON object and I am iterating through this.

But, each iterated object has some child objects where I do need to iterate through them as well.

JSON structure:- [{name: a, t1:v1, t2:v2, t3:{c1:cv1,c2:cv2 ...}}]

This JSON object has (key, value) pair and value can have its children with (key, value) pair again.

I wanted to create labels for each key value pair and for child key value pair also.

Thanks in advance,
Ashok.

What I have tried:


<label style="">{{key}} :</label>
<label style="display:inline-block;">{{value}}</label>

{{attribute}} ({{v}})

Posted
Updated 23-Feb-16 0:15am
Comments
Konstantin A. Magg 21-Feb-16 4:10am    
Did you have a look on the reviver argument for JSON.parse? Their use case looks pretty similar:

> JSON.parse('{"1": 1, "2": 2, "3": {"4": 4, "5": {"6": 6}}}' ...

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse

1 solution

It worked for me

JavaScript
JSON.parse('{"1": 1, "2": 2, "3": {"4": 4, "5": {"6": 6}}}' ...
 
Share this answer
 
Comments
Konstantin A. Magg 23-Feb-16 10:41am    
Good to hear that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900