Why do you need this? There should be no newline characters in the input: JSON requires newlines to be escaped.