views:

19

answers:

2

Hello I am using JSON.stringify for an array of arrays, and it returns this:

'[
  ["<span pt=\"7.5\" idfont=\"Humnst777 Cn BT-Bold\">Javelin</span>","0","0"],
  ["<span idfont=\"Humnst777 Cn BT-Bold\">Javelin&co</span>","0","0"]
 ]';

It is correct but i have to use encodeURIComponent (& present) to post this value with js. The problem is that when I get this data in POST from php with $boxes=json_decode($_POST['data']) it seems to remove slashes eg. pt=\"7.5\" -> pt="7.5" destroying the json object giving this result:

'[
["<span pt="7.5" idfont="Humnst777 Cn BT-Bold" >Javelin</span>","0","0"]
["<span pt="7.5" idfont="Humnst777 Cn BT-Bold" >Javelin&</span>","0","0"]

 ]';

Does any one how to avoid this problem? thanks

A: 

Don't you have magic_quotes activated ? http://www.php.net/manual/en/security.magicquotes.php

MatTheCat
A: 

Try rawurlencode and rawurldecode instead. Ref this for more details

Chinmayee