Skip to content Skip to sidebar Skip to footer

Rendering Tree View From Json Callback

JSON callback returns me formatted dates and only it. Basing on given dates I have to build a tree structure, which will seperate different years, months and days. Oonly dates whic

Solution 1:

It gaves a tree view, but every date is written to the first node

Use JSON.stringify to build a DOM, as in this question:

Javascript: Using reviver function, I seem can't get to alter all the keys, while concating the numbers

If some year has a place in the tree, than another date with the same year should go to the same node level, no create new one

Use a loop to insert each date as the key of an object literal, such as foo, then use JSON.parse to remove duplicate keys. Here is an example:

var foo = {"2000-01-01":"good", "2001-09-11":"bad", "2000-11-02":"ugly", "2000-01-01":"jetson"}
 var bar = JSON.parse(JSON.stringify(foo) )
 var baz = JSON.stringify(bar)

Post a Comment for "Rendering Tree View From Json Callback"