How can I put double quotes inside a string within an ajax JSON response from php?
Just escape it with a backslash:
> JSON.stringify({"a": 5, "b": 'a "kitty" mighty odd'}){"a":5,"b":"a \"kitty\" mighty odd"}> JSON.parse('{"a":5,"b":"a \\"kitty\\" mighty odd"}')Object a: 5 b: a "kitty" mighty odd __proto__: Object
JSON parsers recognize \"
inside double-quoted strings as a double quote. Note that in the second example, the double-backslash is needed because there's a Javascript parser pass, then another JSON parser pass.
A little off-topic, you could use JavaScript/NodeJS on your server and use ES6 template literals (the backticks `` used around "Christian"), but 7 years later you probably already use NodeJS :)
var myJSON = { "name": { "first": `"Christian"`, "last": "Broberg" }, "age": 49, "skills": [ "JavaScript", "React", "NodeJS" ], "married": false, "superpowers": null}