I'm trying to pass a JSON string containing list of objects and decode it in php using json_decode()
, I've tried many posts on StackOverflow but nothing worked. Here's what I'm trying to do:
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);
if I echo $d;
it shows perfect result but var_dump($ar, $obj);
both are NULL
I've also read this so its not the same. json_decode() returns null issues