0
我目前有一個硬編碼的json文件。這裏是一個片段:使用mysql查詢創建嵌套的json對象
{
"name": "Projects",
"children": [
{
"name":"Project_Category(example:MobileApps)",
"description":"category",
"children": [{
"name":"Sub_category(example:MusicPlayer)",
"description":"some_description(example:The music app will play music from an android device...)",
"children":[
{//child 1 of the MusicPlayer subcategory
"name": "Actual_project_name(example:JukeBox)",
"description":"Actual_project_description",
"children":[
{"name":"projectGroupMember1", "email":"[email protected]"},
{"name":"projectGroupMemeber2", "email":"[email protected]"}
]},
{ //child 2 of the MusicPlayer subcategory
"name": "another_project_title",
"description":"another_project_description",
"children":[
{"name":"projectGroupMember1", "email":"[email protected]"},
{"name":"projectGroupMember2", "email":"[email protected]"}
]
}
]//end of MusicPlayer's children
}, //end of MobileApps children
...
擁有所有這些數據存儲在數據庫中,我一直在試圖使用PHP和嵌套的MySQL查詢生成這個輸出,我將用於其他任務的JSON文件(數據視覺)。我的目標是在每次打開Web應用程序時生成該文件,以便從數據庫獲得最新的版本。但是,我一直在使用嵌套mysql查詢來創建這個輸出有困難。所以我的問題是,鑑於我的json文件的結構是可行的嗎?我應該做更好的方法嗎?任何建議都會有幫助。
爲什麼要在嵌套的SQL查詢中做到這一點?分而治之,並建立通過一步一步的JSON。並非一切都需要一步做 – MatthiasLaug 2013-04-21 12:58:35
您需要提供更多的信息。你的數據庫結構是什麼樣的?你有什麼嘗試? – alexn 2013-04-21 13:02:47