我目前有一个硬编码的 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":"groupMember1Email@yahoo.com"},
{"name":"projectGroupMemeber2", "email":"groupMember2Email@yahoo.com"}
]},
{ //child 2 of the MusicPlayer subcategory
"name": "another_project_title",
"description":"another_project_description",
"children":[
{"name":"projectGroupMember1", "email":"groupMember1Email@gmail.com"},
{"name":"projectGroupMember2", "email":"groupMember2Email@gmail.com"}
]
}
]//end of MusicPlayer's children
}, //end of MobileApps children
...
拥有一个存储所有这些数据的数据库,我一直在尝试使用 php 和嵌套的 mysql 查询将此输出生成到一个 json 文件,我将用于其他任务(数据可视化)。我的目标是在每次打开 Web 应用程序时生成这个文件,这样我就可以从数据库中获得它的最新版本。但是,我在使用嵌套的 mysql 查询来创建此输出时遇到了困难。所以我的问题是,考虑到我的 json 文件的结构方式,这可行吗?我应该做更好的方法吗?任何建议都会有所帮助。