class EscapeJson {

    public String escapeJson(final String text) {
        String revisedText = null;
        if (text != null) {
            StringBuilder sb = new StringBuilder(text.length() * 2);
            for (int i = 0; i < text.length(); i++) {
                char c = text.charAt(i);
                switch (c) {
                case '\"':
                    sb.append("\\\"");
                    break;
                default:
                    sb.append(c);
                }
            }
            //with escaped string we return
            revisedText = sb.toString();
        }
        return revisedText;
    }

}