Do i need to apply htmlspecialchars / htmlentites on json array?

Posted by Imran Omar Bukhsh on Stack Overflow See other posts from Stack Overflow or by Imran Omar Bukhsh
Published on 2012-09-08T15:12:43Z Indexed on 2012/09/08 15:38 UTC
Read the original article Hit count: 625

I wanted to ask that in a php script of mine which I am accessing through an ajax request, I am returning json data ( converted from an array ) as such

 echo json_encode($row_array);

I get this data in jquery and display it in a form. Do i need to apply htmlspecialchars / htmlentites before returning the data?

Is do then whats the correct way to do it? The following code gives me an error:

echo htmlentities(json_encode($row_array));

Thanking you Imran

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery