Here you can find the source of jsonEscapes(String str)
private static String jsonEscapes(String str)
//package com.java2s; //License from project: Open Source License public class Main { private static String jsonEscapes(String str) { // System.out.println("ESCAPING "+str); StringBuilder escaped = new StringBuilder(); for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0: continue; case '\b': escaped.append("\\\\b"); continue; case '\t': escaped.append("\\\\t"); continue; case '\n': escaped.append("\\\\n"); continue; case '\f': escaped.append("\\\\f"); continue; case '\r': escaped.append("\\\\r"); continue; case '\"': escaped.append("\\\\\""); continue; case '\\': escaped.append("\\\\\\"); continue; default: escaped.append(str.charAt(i)); continue; }//from ww w . ja v a 2 s . co m } return escaped.toString(); } }