I have the ungrateful task to build a JSON String in Java, manually, without any framework, just a StringBuilder. I know this is bad, but it is only part of a prototype, I w
"\"Some text WITH quotes\", slashes: /foo and backslashes \\foo"
translates to:
"Some text WITH quotes", slashes: /foo and backslashes \foo
You can use StringEscapeUtils.escapeJavaScript() in apache-commons Lang 2.6 or StringEscapeUtils.escapeEcmaScript() in 3.4 to do the hard-work of escaping for you.