private static void jsonEncodeString(String string, StringBuilder sb) {
        CharacterIterator ci = new StringCharacterIterator(string);
        sb.append('"');
        for (char c = ci.first(); c != CharacterIterator.DONE; c = ci.next()) {
            switch (c) {
                case '\"':
                    sb.append("\\\"");
                    break;
                case '\\':
                    sb.append("\\\\");
                    break;
                case '\b':
                    sb.append("\\b");
                    break;
                case '\f':
                    sb.append("\\f");
                    break;
                case '\n':
                    sb.append("\\n");
                    break;
                case '\r':
                    sb.append("\\r");
                    break;
                case '\t':
                    sb.append("\\t");
                    break;
                default:
                    sb.append(c);
                    break;
            }
        }
        sb.append('"');
    }