JSON解码返回NULL

时间:2015-11-13 18:55:00

标签: php arrays json curl

我向网址发出curl请求,得到了这个JSON $data返回

{"status":200,"message":"Success","data":[{"cpe_mac":"665544332211","device_mac":"223344556677","device_activity":"INACTIVE","dhcp_lease_held":"CONNECTED_DEVICE_DHCP_LEASE_NOT_AVAILABLE","ip_address":"127.0.0.3","vlan_id":1002,"hostname":"babyhost","dhcp_lease_start_time":400,"dhcp_lease_length":600,"interface":"WIRELESS","ssid":"2219","port_ranges":[{"startport":0,"endport":06000:6500}],"last_updated_utc_in_secs":1446061806668}]}

然后,我解码 $raw = json_decode($data, true);

当我打印出来时,我得到null

dd($raw); // null

我只想将json转换为数组并访问它。

非常感谢任何关于此的提示!

2 个答案:

答案 0 :(得分:2)

这部分:

[{"startport":0,"endport":06000:6500}]
您的JSON的

无效。 06000:6500不是有效的属性值。修好后,json_decode正常工作。

答案 1 :(得分:2)

返回的json无效

enter image description here