Java examples for java.lang:String Escape
Escapes json characters in the passed string
//package com.java2s; public class Main { /**/* w ww . j av a 2s .c o m*/ * Escapes json characters in the passed string * @param s The string to esacape * @return the escaped string */ public static String jsonEscape(CharSequence s) { return s.toString().replace("\"", "\\\"").replace("[", "\\[") .replace("]", "\\]").replace("{", "\\{") .replace("}", "\\}"); } }