dongna9185 2013-09-26 04:12
浏览 80
已采纳

json_decode返回空数组

I have a curl command which outputs the following:

"{"meta":{"code":200},"data":{"username":"monstore","bio":"Art clothing line with our life scary tales as the imagination. info@heymonstore.com \/ +6281213162069 \/ BB PIN 293A4565","website":"http:\/\/www.heymonstore.com","profile_picture":"http:\/\/images.ak.instagram.com\/profiles\/profile_4472462_75sq_1354349840.jpg","full_name":"Monstore","counts":{"media":547,"followed_by":6472,"follows":129},"id":"4472462"}}"

Here's the curl command:

  $output = curl_exec($ch); 

Basically the above is what $output prints out. So I tried to decode this by doing:

$userinfo = json_decode($output, false);

however it returns an empty array. Any idea why?

  • 写回答

2条回答 默认 最新

  • doushi3715 2013-09-26 04:19
    关注
    $userinfo = json_decode($output, true);
    

    you need to specify you want an associative array instead of an object from json_decode:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?