2009-01-21 124 views

回答

4

你从哪里得到那么大的JSON字符串?

按照json_decode文档,如果JSON是在某些方面畸形的,它只会返回NULL,这是我收到的时候我尝试brother.php

// the following strings are valid JavaScript but not valid JSON 

// the name and value must be enclosed in double quotes 
// single quotes are not valid 
$bad_json = "{ 'bar': 'baz' }"; 
json_decode($bad_json); // null 

// the name must be enclosed in double quotes 
$bad_json = '{ bar: "baz" }'; 
json_decode($bad_json); // null 

// trailing commas are not allowed 
$bad_json = '{ bar: "baz", }'; 
json_decode($bad_json); // null 

编辑

我通过JSONLint(一个JSON验证器)运行了两个JSON文件,并且正如所料,brother+a文件已通过,而brother在几个位置出现故障。

+0

感谢您的链接,正是我期待这么久...... – 2009-01-21 20:46:43