@Override
    public void writeByteRange(boolean utf8String, int fieldNumber, byte[] value,
            int offset, int length, boolean repeated) throws IOException
    {
        final WriteSink sink = this.sink;
        if (utf8String)
        {
            if (lastNumber == fieldNumber)
            {
                // repeated field
                tail = sink.writeByte(
                        QUOTE,
                        this,
                        writeUTF8Escaped(
                                value, offset, length,
                                sink,
                                this,
                                sink.writeByteArray(
                                        COMMA_AND_QUOTE,
                                        this,
                                        tail)));
                return;
            }

            tail = sink.writeByte(
                    QUOTE,
                    this,
                    writeUTF8Escaped(
                            value, offset, length,
                            sink,
                            this,
                            writeKey(
                                    fieldNumber,
                                    sink,
                                    repeated ? KEY_SUFFIX_ARRAY_STRING : KEY_SUFFIX_STRING)));

            lastNumber = fieldNumber;
            lastRepeated = repeated;
            return;
        }

        if (lastNumber == fieldNumber)
        {
            // repeated field
            tail = sink.writeByte(
                    QUOTE,
                    this,
                    sink.writeByteArrayB64(
                            value, offset, length,
                            this,
                            sink.writeByteArray(
                                    COMMA_AND_QUOTE,
                                    this,
                                    tail)));
            return;
        }

        tail = sink.writeByte(
                QUOTE,
                this,
                sink.writeByteArrayB64(
                        value, offset, length,
                        this,
                        writeKey(
                                fieldNumber,
                                sink,
                                repeated ? KEY_SUFFIX_ARRAY_STRING : KEY_SUFFIX_STRING)));

        lastNumber = fieldNumber;
        lastRepeated = repeated;
    }
Returns true if the last written field was a repeated field.
protostuff-json/src/main/java/io/protostuff/JsonXOutput.java