3

我是 JSON 的新手,在阅读完每篇文章后,我仍然无法从 php 编码数组中解析数组

如果它只有一个项目 init,我已经设法让它解析数组。但是如果有多个项目,它会输出 null,因为它存储了太多的值。

我将如何从这个数组中列出第二个“消息”

{"date":"Friday 10 Aug 2012","time":"2:08","message":"好吧,伙计们,新网站几乎要竞争了'然后它永远不会完成,它将建立和建立直到它接管了!"}{"date":"Wednesday 8 Aug 2012","time":"9:08","message":"昨天洗脑先生的采访让我崩溃了。太好了,我压力很大等待得到它。是的 55rocks!“}

4

1 回答 1

1

您的数组不是有效的 JSON 变量

您需要用逗号(,) 分割每条记录。并添加方括号

[ /你的代码/ ]

试试这个代码

[
{
  "date": "Friday 10 Aug 2012",
  "time": "2:08",
  "message": "Well guys the new website is almost compete' then again its never going to be complete it will build and build until it takes over!"
}
,

{
  "date": "Wednesday 8 Aug 2012",
  "time": "9:08",
  "message": "Mr brainwash interview yesterday left my shattered. Was so good and I had been so stressed waiting to get it. Yes 55rocks! "
}
]

使用此链接查看每个 json 值数组。

于 2012-08-12T17:08:12.397 回答