我想將MySQL數據庫數據轉換爲json格式。我的文件需要嵌套父母和孩子的格式。 (請參閱片段)這是因爲我試圖使用d3數據可視化(可摺疊樹佈局),它要求以某種方式格式化json數據。下面我附加了我所看到的json文件的片段。我有一些問題試圖編寫嵌套的SQL語句來做到這一點。我還附加了我的數據庫視圖,以瞭解我正在處理的內容。任何建議都會有很大幫助。謝謝! 試圖將MySQL數據轉換爲d3的嵌套json文件?
我試圖讓JSON格式是這樣的:
{
"name": "Projects",
"children": [
{
"name":"category_name#1", "description":"category",
"children": [
{
"name":"sub_category_name1",
"description":"category description text here",
"children":[
{"name": "project1",
"description":"project 1 text goes here",
"children":[
{"name":"mike", "email":"[email protected]"},
{"name":"dan", "email":"[email protected]"}
]
},
{
"name": "project2",
"description":"project 2 text goes here",
"children":[
{"name":"steve", "email":"[email protected]"},
{"name":"chris", "email":"[email protected]"}
]
}
]
},
{
"name": "sub_category_name2",
"description":"sub category description text goes here..",
"children": [
{"name": "project3",
"description":"project3 text goes here ",
"children":[
{"name":"Alex", "email":"[email protected]"}
]
}
]
}
]
},
.
. //more categories with children of subcategories and sub_cat children of projects
.
}
上使用的語言頁面請求動態生成的(是哪一個?紅寶石?蟒蛇?PHP的?),或者只是傾銷的現狀進行靜態文件由D3讀? – minikomi 2013-04-24 02:02:56
對不起,沒有提及它。我使用PHP和動態的頁面請求。 – user1899872 2013-04-24 03:51:33