我正在将一个数组从php json_encode()转换成json。如果我为一个数组编码它,我可以解码它,但是当它是这样的时候:array('a'=>array(0=>array(),1=>array())),它返回{"a":[[],[]]}
当我对它进行解码时,我得到以下错误
Catchable fatal error: Object of class stdClass could not be converted to stringjson源
json是here
发布于 2013-02-05 18:28:01
在json_decode中使用true作为第二个参数
$arr = json_decode($your_array,true); // it will create array工作示例http://codepad.viper-7.com/0Dxxm8
发布于 2013-02-05 20:20:03
这是一个有效的json,而且它已经是一个json了,所以不需要解析这个json。
var json={};//copy json from http://pastebin.com/rLw4ABwS
console.log(json);在fiddle http://jsfiddle.net/rRNSN/上测试代码
在控制台中检查它作为对象返回意味着它是有效的json,如果它将是一个字符串,那么它需要使用JSON.parse()或通过jquery.parseJSON()进行解析。
https://stackoverflow.com/questions/14705218
复制相似问题