Gowri
Gowri

Reputation: 16845

show double quotes inside(JSON) jquery datatables

I am using jquery data tables server side method

example here http://www.datatables.net/examples/server_side/server_side.html

My JSON RESPONSE( example)

 {"sEcho": 0, "iTotalRecords": 8, "iTotalDisplayRecords": 8, "aaData":
  [ ["1","3D Panasonic VIERA 50' LED Television","Electronics" ],
["2","Wireless Telephone Set - 3 in 1","Electronics" ]] }

you can note 3D Panasonic VIERA 50' LED Television single quote in that string this works fine. but using 3D Panasonic VIERA 50" LED Television double quote that makes JSON PARSE ERROR

how can i escape that double quote inside json and how can i display exactly 3D Panasonic VIERA 50" LED Television like this in grid

Upvotes: 1

Views: 3383

Answers (2)

Gowri
Gowri

Reputation: 16845

Wow very simple i found myself

function getJsondata($str){
return htmlspecialchars(stripslashes($str));
}

this function strips the \ and it also displays the " on the grid without parse error

Thanks

Upvotes: 0

jartur
jartur

Reputation: 539

JSON standard specifies \" as an escape sequence for a double quote within a string.

Upvotes: 1

Related Questions