Here you can find the source of jsonEscape(String in)
Parameter | Description |
---|---|
in | value to escape |
public static String jsonEscape(String in)
//package com.java2s; public class Main { /**//from w w w. ja va 2s .c o m * Escape value to be used in JSON. * * @param in value to escape * @return JSON escaped value */ public static String jsonEscape(String in) { if (in == null || in.isEmpty()) return in; return in.replace("\\", "\\\\").replace("\n", "\\n").replace("\"", "\\\"").replace("\r", "\\r") .replace("\t", "\\t").replace("\b", "\\b").replace("\f", "\\f"); } }