I am handling questions and answers(stored somewhere) in my forum using JSON.parse() function. For a response like
response = {"Q":"What is PHP","reply":"Google it"}
it works fine but in case user input something with inverted commas I face problems e.g.
response = {"Q":"What is PHP","reply":"Google **"what is php"**"}
How would i escape those inverted commas?
from javascript use encodeUriComponent
from php use urlencode
Prefix any embedded double-quotes with a backslash:
response = {"Q":"What is PHP","reply":"Google \"what is php\""}
Escape it
response = {"Q":"What is PHP","reply":"Google **\"what is php\"**"}