Hi I am getting a weird issue in JSON decode, JSON is getting decoded correctly locally, but on my server the json_decode function returns NULL.
This is the JSON that I am posting from my test page:
[
{
"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
}
]
now when I do var_dump(json_deocde($_POST['data'], true)); I get NULL response.
when I do echo $_POST['data']; I get:
[ { \"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 } ]
I think due to these \" json_decode is not working, kindly help me in fixing this issue,
Some Server Info:
PHP Version 5.2.17 json version 1.2.1
2 Answers 2
You have magic quotes enabled on your server. Disable them.
3 Comments
you can always do this : var_dump(json_deocde(str_replace("\",$_POST['data']), true));
that would remove the slashes from your json string