I searched and read most of the related topics, but they weren\'t what I was looking for.
I\'ve a JSON enocded string with json_encode PHP function:
However when I make a change in JSON encoded string - adding Backslash to single quote
That escapes it in the PHP string literal. It is then inserted into the PHP string as a simple '.
If you want to escape it before inserting it into JavaScript then you need to add slashes to the string you get out of json_encode (or rather, since you aren't using that (you should be!) the JSON string you build by hand).
That is more work then you need though. The real solution is to remember that JSON is a subset of JavaScript literal syntax:
var obj = =$data?>;