JSON.stringify doesn't escape? JSON.stringify doesn't escape? json json

JSON.stringify doesn't escape?


stringify the object twice does the trick

console.log(JSON.stringify(JSON.stringify({"console":{"free":false}})));// "{\"console\":{\"free\":false}}"


It doesn't escape characters, no, there's encodeURIComponent for that, and you can use them together, as in encodeURIComponent(JSON.stringify(obj))


The quotes around property names are not supposed to be escaped, only quotes inside strings. Your JSON is fine :)