当传递包含对象列表的JSONstring时,json_decode在PHP中返回null

时间:2017-04-16 16:17:34

标签: php

我试图传递包含对象列表的JSON字符串并使用json_decode()在php中对其进行解码,我在StackOverflow上尝试了很多帖子但没有任何效果。这就是我要做的事情:

JSON

"[{"description":"null","endDate":"2017-04-17","endTime":"15:00:00","eventID":"vmkqad951217ifc2a1j5ic9154","eventTitle":"Some Task","startDate":"2017-04-17","startTime":"14:00:00"},{"description":"here\u0027s the description","endDate":"2017-04-20","endTime":"19:30:00","eventID":"eq5ddd8rbhctf8gfcjh7t9r3o8","eventTitle":"Another task","startDate":"2017-04-20","startTime":"18:30:00"},{"description":"null","endDate":"2017-04-21","endTime":"16:00:00","eventID":"6dnrh44jspqlslqpdnujpk9btg","eventTitle":"Twother task","startDate":"2017-04-21","startTime":"15:00:00"}]"

PHP

$d = $_POST['data'];
$ar = json_decode($d,true);
$obj = json_decode($d);
var_dump($ar,$obj);

如果我echo $d;它显示了完美的结果,但var_dump($ar, $obj);都是NULL

我也读过这个,所以它不一样。 json_decode() returns null issues

0 个答案:

没有答案