protected void writeString(String text) throws IOException {
        out.write('"');
        for (char c : text.toCharArray()) {
            switch (c) {
            case '"':
            case '\\':
            case '/':
                out.write('\\');
                out.write(c);
                break;
            case '\t':
                out.write("\\t");
                break;
            case '\n':
                out.write("\\n");
                break;
            case '\r':
                out.write("\\r");
                break;
            case '\f':
                out.write("\\f");
                break;
            case '\b':
                out.write("\\b");
                break;
            default:
                out.write(c);
                break;
            }
        }
        out.write('"');
    }