AlexB
AlexB

Reputation: 2184

JSON data cannot be accessed in PHP version 5.2.17

the JSON passes string in the following format:

params{"visitor":"","submitted":"submitted","date":"02/28/2015"}

now the problem,

I am trying to check in in my PHP file the "visitor", "submitted" and "date", but all of it comes empty for some reason. I have also tried the following:

$json = $_POST['params'];
var_dump(json_decode($json));

but the result is NULL

can you please help me a little as I have tried almost everything that I could possibly try but nothing worked so far.

also if I am doing var_dump($_POST['params']); then I get the following:

string(1035) "{\"visitor\":\"\",\"submitted\":\"submitted\",\"date\":\"02/28/2015\"}"

Upvotes: 0

Views: 258

Answers (1)

Simone Melloni
Simone Melloni

Reputation: 430

Working on PHP 5.2.17 you must need to use stripslashes() with the $_POST variable like this $post = json_decode(stripslashes($_POST['data']));
Hope it helps

Upvotes: 2

Related Questions