I am creating a web application that needs to process nested geographic data both for displaying in a tree and for searching. The source data looks something like this:
id:1, name:UK
id:2: name: South-East, parentId: 1
id:3: name: South-West, parentId:1
id:4: name: Berkshire, parentId: 2
id:5: name: Reading, parentId: 4
and I want it to look something like this:
id:1: name UK, children[
{id: 2, name: South-East, children:[
{id:4: name: Berkshire, children: [
{id:5: name: Reading}
]
},
{id:3: name: South-West}
]
so each geographic location has a "children" array property that contains all subzones, each of which has a different "children" array property, etc. It might also make sense to have a βparentβ property, so I could move from any child to its parent.
- , , , .
, JavaScript (, jLinq , ), , . - JavaScript - /, ?