thrifty-runtime/src/main/java/com/microsoft/thrifty/protocol/JsonProtocol.java
private void writeJsonString(byte[] b) throws IOException {
        context.write();
        transport.write(QUOTE);
        int len = b.length;
        for (int i = 0; i < len; i++) {
            if ((b[i] & 0x00FF) >= 0x30) {
                if (b[i] == BACKSLASH[0]) {
                    transport.write(BACKSLASH);
                    transport.write(BACKSLASH);
                } else {
                    transport.write(b, i, 1);
                }
            } else {
                tmpbuf[0] = JSON_CHAR_TABLE[b[i]];
                if (tmpbuf[0] == 1) {
                    transport.write(b, i, 1);
                } else if (tmpbuf[0] > 1) {
                    transport.write(BACKSLASH);
                    transport.write(tmpbuf, 0, 1);
                } else {
                    transport.write(ESCSEQ);
                    tmpbuf[0] = hexChar((byte) (b[i] >> 4));
                    tmpbuf[1] = hexChar(b[i]);
                    transport.write(tmpbuf, 0, 2);
                }
            }
        }
        transport.write(QUOTE);
    }
private void writeJsonString(byte[] b) throws IOException {
        context.write();
        transport.write(QUOTE);
        int len = b.length;
        for (int i = 0; i < len; i++) {
            if ((b[i] & 0x00FF) >= 0x30) {
                if (b[i] == BACKSLASH[0]) {
                    transport.write(BACKSLASH);
                    transport.write(BACKSLASH);
                } else {
                    transport.write(b, i, 1);
                }
            } else {
                tmpbuf[0] = JSON_CHAR_TABLE[b[i]];
                if (tmpbuf[0] == 1) {
                    transport.write(b, i, 1);
                } else if (tmpbuf[0] > 1) {
                    transport.write(BACKSLASH);
                    transport.write(tmpbuf, 0, 1);
                } else {
                    transport.write(ESCSEQ);
                    tmpbuf[0] = hexChar((byte) (b[i] >> 4));
                    tmpbuf[1] = hexChar(b[i]);
                    transport.write(tmpbuf, 0, 2);
                }
            }
        }
        transport.write(QUOTE);
    }
Write the bytes in array buf as a Json characters, escaping as needed