Skip to content

Instantly share code, notes, and snippets.

@meub
Created July 26, 2013 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meub/6091400 to your computer and use it in GitHub Desktop.
Save meub/6091400 to your computer and use it in GitHub Desktop.
Prevent parseJSON from barfing on line breaks.
function parse(text) {
text = str_replace("\r\n", "\n", text);
text = str_replace("\r", "\n", text);
text = str_replace("\n", "\\n", text);
return text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment