How to escape string in JSON? Seems that JSON will escape back slashes.
How do I json_encode(array('name'=>'what\'s the name'))?
How to escape string in JSON? Seems that JSON will escape back slashes. How
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well firstly, you can start by doing this:
PHP, Python, Javascript, etc. all allow the use of both single- and double-quotes for just such an occasion. Use them!
Secondly, the way you want to do this is probably not just
', but\', which means you actually need\\\'. Try this:Thirdly, since you’re getting the information from
$_POST, the string is already known-good. Simply: