Skip to content

Instantly share code, notes, and snippets.

@JohannesHoppe
Created July 15, 2014 06:27
Show Gist options
  • Save JohannesHoppe/82c1ae49666bb84a3a4b to your computer and use it in GitHub Desktop.
Save JohannesHoppe/82c1ae49666bb84a3a4b to your computer and use it in GitHub Desktop.
JavaScript-stringify with support for U+2028 and U+2029 characters
var saveStringify = function (obj) {
return JSON.stringify(obj)
.replace(/\u2028/g, '\\u2028')
.replace(/\u2029/g, '\\u??2029');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment