2009-01-21 119 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