I intercept a form post using jQuery. With form fields, I create a JSON object that is stored in a hidden form field. The value that is passed to the form field is similar to the following:
{"Status" : "Closed", "Location" : "Glasgow", "Date" : "2012-02-15"}
But if I repeat the object from the $ _POST variable:
echo $_POST['JSON'];
Outputs the following:
{\"Status\" : \"Closed\", \"Location\" : \"Glasgow\", \"Date\" : \"2012-02-15\"}
I tried running this through stripslashes () and urldecode (), but I had no joy. I understand that I could just replace the backslashes with a replace function, but this is too much hacking.
Has anyone come across this failed json via mail before?
Note. . This is on the back of the Wordpress site. I am not sure if this will cause this effect.
source share