好吧,所以我想从nedb数据库转换我的数据,看起来像这样...
{"Users_Connected":1,"level":0,"Connected_By":"ylSQncqFKw5hx7iI","User_1":"XR9S3xTbztGZ7yfg","User_2":"none","User_3":"none","_id":"DmAMl1tMsuZ3AN6I"}
{"Users_Connected":0,"level":0,"Connected_By":"ylSQncqFKw5hx7iI","User_1":"none","User_2":"none","User_3":"none","_id":"GtBiic0mf7cNTjZN"}
{"Users_Connected":0,"level":0,"Connected_By":"DmAMl1tMsuZ3AN6I","User_1":"none","User_2":"none","User_3":"none","_id":"XR9S3xTbztGZ7yfg"}
{"Users_Connected":0,"level":0,"Connected_By":"ylSQncqFKw5hx7iI","User_1":"none","User_2":"none","User_3":"none","_id":"ncetzWYjG0LCIt3a"}
{"Users_Connected":4,"level":"1","Connected_By":"none","User_1":"DmAMl1tMsuZ3AN6I","User_2":"GtBiic0mf7cNTjZN","User_3":"ncetzWYjG0LCIt3a","_id":"ylSQncqFKw5hx7iI"}
到d3.js树形视图的json对象(使用课程中的javascript)...
每个用户都有其自己的ID,“ Connected_By”具有父用户ID(由该用户连接)的ID,每个用户还具有一个User_1,2,3。另外,具有Connected_By =='none'的用户必须作为该节点下正在连接的每个节点用户的父级都位于顶部。
我想要的是像数据结构一样的父/子层次结构。
类似这样的东西...
[
{
"name": "ylSQncqFKw5hx7iI",
"children": [
{
"name": "DmAMl1tMsuZ3AN6I",
"children": [{
"name": "XR9S3xTbztGZ7yfg"
}]
},
{
"name": "GtBiic0mf7cNTjZN"
},
{
"name": "ncetzWYjG0LCIt3a"
}
]
}
]
任何建议或建议都会对我有很大帮助...而且,我是初学者,所以请不要介意...
先谢谢您了:)