Php mySQL表中嵌套的JSON数组是什么样子的?

Php mySQL表中嵌套的JSON数组是什么样子的?,php,mysql,json,nested,Php,Mysql,Json,Nested,我有一个手动构建的json文件,类似于: { "Thing": [ { "post": "blah", "comments": [ { "text": "blahblah" }, { "text": "blahblahblah" } ] } } 我正在尝试用PHP做一个JSON->mySQL表。 我对mySQ

我有一个手动构建的json文件,类似于:

{
  "Thing": [
   {
      "post": "blah",
      "comments": [
          {
             "text": "blahblah"
          },
          {
             "text": "blahblahblah"
          }
       ]
   }
}
我正在尝试用PHP做一个JSON->mySQL表。

我对mySQL表的理解是“Thing”将是表的标题;“post”和“comments”将是列标题。如果有任何错误,请纠正我。

因此,我对具有“文本”的嵌套对象数组以及在表格式中应该如何“显示”感到困惑,并且在尝试填充mySQL表时,我应该如何处理json字符串中的嵌套值感到困惑。


非常感谢

您必须创建一个关联:

第一个表是:

  Posts
  id title text
 Comments
 id post_id text
第二个表是:

  Posts
  id title text
 Comments
 id post_id text
当你寻找你的评论时,你只需打电话

SELECT * FROM comments WHERE post_id = 'yourpostid'

对于您的json,请查看json_解码和json_编码。这将更加简单。

至于填充表,您将使用foreach循环。