I need to represent this hierarchy in a JSON object. Can someone help me out ?
- John
--- Lee
------ Nash
--------- Tim
------ Nicole
------ Kelly
--- Alice
--- Stanley
{
"name": "John",
"children": [
{
"name": "Lee",
"children": [
{
"name": "Nash",
"children": [{ "name":"Tim"}]
},
{
"name": "Nicole"
},
{
"name": "Kelly"
}
]
},
{
"name": "Alice"
},
{
"name": "Stanley"
}
]
}
How about this:
{
"John" : {
"Lee" : {
"Nash" : {
"Tim" : null
},
"Nicole" : null,
"Kelly" : null
},
"Alice" : null,
"Stanley" : null
}
}
The relationship, whether it be children or otherwise, is implied by the tree hierarchy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With