-3

My shared web hosting adds \ to JSON. I use ExtJS and it normally sends this data

[{"property":"id","direction":"ASC"}]

Howere PHP receives or chages it as [{\"property\":\"id\",\"direction\":\"ASC\"}]

Thus I cannot use json_decode($_REQUEST['sort'])

I think this is because they wanted to prevent SQL injection but now they break my application. What I have to do?

Edit:

$sort = json_decode($_GET['sort']);
print_r($_GET); // [sort] => [{\"property\":\"id\",\"direction\":\"ASC\"}]
print_r($sort); //
ilhan
  • 8,700
  • 35
  • 117
  • 201

1 Answers1

0

Please check, if you vHost has magic quotes enabled.

Someone over here proposed this to get the unchanged values:

if (get_magic_quotes_gpc()) {

    function strip_array($var) {

        return ( is_array($var)
               ? array_map("strip_array", $var)
               : stripslashes($var)
               );
    }

    $_POST = strip_array($_POST);
    $_SESSION = strip_array($_SESSION);
    $_GET = strip_array($_GET);

}
SteAp
  • 11,853
  • 10
  • 53
  • 88