【发布时间】:2012-04-13 09:33:41
【问题描述】:
我有以下 json
country_code({"latitude":"45.9390","longitude":"24.9811","zoom":6,"address":{"city":"-","country":"Romania","country_code":"RO","region":"-"}})
我只想要 country_code,我该如何解析它?
我有这个代码
<?php
$json = "http://api.wipmania.com/jsonp?callback=jsonpCallback";
$jsonfile = file_get_contents($json);
var_dump(json_decode($jsonfile));
?>
它返回NULL,为什么?
谢谢。
【问题讨论】:
-
在你做
file_get_contents之后,你的$jsonfile变量的值是多少? -
执行
var_dump($jsonfile)并将输出添加到问题 -
var_dump($jsonfile) = string(144) "jsonpCallback({"latitude":"45.9390","longitude":"24.9811","zoom":6,"address":{" city":"-","country":"Romania","country_code":"RO","region":"-"}})"
标签: php file-get-contents json