json_decode函数是否有大小限制?

时间:2015-07-13 15:47:58

标签: php

所以我试图保存从URL获取的feed并将其写入名为new.json的文件。在将文件写入文件后,然后使用json_decode函数存储信息,但无法检索信息。我知道代码是有效的,因为我已经用另一个文件测试它并且它可以工作,但是文件是jus 6.45KB而new.json文件超过3MB。

我需要来自url的数据来更新数据库,但我无法,因为它不会从文件中产生信息,所以我想知道文件是否太大。

感谢。

$new_props = $property->getData($URL); //Set Method to retrieve  property
$file = fopen("new.json","w+")or die("Error opening output file");
echo fwrite($file,json_encode($new_props));
fclose($file);

$ourFileName = "new.json";
$mydata = file_get_contents($ourFileName);
$json_array = json_decode($mydata, TRUE);

if (is_null($json_array)) {
    echo'<br /> json decode failed. Error handling here. <br />';
}
$id = $json_array[property][1][id];
$area = $json_array[property][1][area];
echo "<br /> id:".$id ."<br /> area:".$area;

1 个答案:

答案 0 :(得分:1)

您的JSON文件无效。查看第95053行,查看"description": "... kind 2 bedroom, 2 1\2 bathroom ..."您有未转义退格的地方。逃避这一点(使用\\),它应该可以工作。

相关问题