JSON解码中的问题


Issue in JSON Decode

嗨,我在JSON解码中遇到了一个奇怪的问题,JSON在本地得到了正确的解码,但在我的服务器上,JSON_decode函数返回NULL。

这是我在测试页面上发布的JSON:

[
  {
    "pictureTaken": 0,
    "unit_id": 20192,
    "id": 2,
    "deficiency_id": 155,
    "last_modifier_id": 4,
    "comments": "Living room",
    "level": 3,
    "location": "Living room",
    "property_id": 26,
    "inspectable_item_id": 44,
    "building_id": -769876698
  }  
]

现在,当我执行var_dump(json_deocde($_POST['data'], true));时,我得到NULL响应。

当我做echo $_POST['data'];时,我得到:

[ { '"pictureTaken'": 0, '"unit_id'": 20192, '"id'": 2, '"deficiency_id'": 155, '"last_modifier_id'": 4, '"comments'": '"Living room'", '"level'": 3, '"location'": '"Living room'", '"property_id'": 26, '"inspectable_item_id'": 44, '"building_id'": -769876698 } ]

我认为由于这些'" json_decode不起作用,请帮助我解决这个问题,

一些服务器信息:

PHP 5.2.17版json版本1.2.1

您的服务器上启用了魔术引号。禁用它们。

您可以始终执行以下操作:var_dump(json_deocde(str_replace("''",$_POST['data']),true);

这将从json字符串

中删除斜杠