I am using spacetree chart and I require JSON in hierarchical format. See sample required JSON format here. I have ID,ParentID,Name,Description fields in Mysql database table. Now How can I convert data in Hierarchical/nested JSON using PHP?
I know json_encode($array). But, I require nested/Hierarchical php array for this.
Let me know to do this.
I am using spacetree chart and I require JSON in hierarchical format. See sample
Share
You’re basically asking two questions here – 1) how to get an hierarchical php structure from a db table and 2) how to encode this structure in json. For the first question see, for example, my (old but working) code. For the second, I believe simple json_encode will work pretty well.