private LinkedBuffer writeKey(final int fieldNumber, final WriteSink sink,
            final byte[] keySuffix) throws IOException
    {
        if (numeric)
        {
            if (lastRepeated)
            {
                return sink.writeByteArray(
                        keySuffix,
                        this,
                        sink.writeStrFromInt(
                                fieldNumber,
                                this,
                                sink.writeByteArray(
                                        END_ARRAY__COMMA__QUOTE,
                                        this,
                                        tail)));
            }

            if (lastNumber == 0)
            {
                return sink.writeByteArray(
                        keySuffix,
                        this,
                        sink.writeStrFromInt(
                                fieldNumber,
                                this,
                                sink.writeByte(
                                        QUOTE,
                                        this,
                                        tail)));
            }

            return sink.writeByteArray(
                    keySuffix,
                    this,
                    sink.writeStrFromInt(
                            fieldNumber,
                            this,
                            sink.writeByteArray(
                                    COMMA_AND_QUOTE,
                                    this,
                                    tail)));
        }

        if (lastRepeated)
        {
            return sink.writeByteArray(
                    keySuffix,
                    this,
                    sink.writeStrAscii(
                            schema.getFieldName(fieldNumber),
                            this,
                            sink.writeByteArray(
                                    END_ARRAY__COMMA__QUOTE,
                                    this,
                                    tail)));
        }

        if (lastNumber == 0)
        {
            return sink.writeByteArray(
                    keySuffix,
                    this,
                    sink.writeStrAscii(
                            schema.getFieldName(fieldNumber),
                            this,
                            sink.writeByte(
                                    QUOTE,
                                    this,
                                    tail)));
        }

        return sink.writeByteArray(
                keySuffix,
                this,
                sink.writeStrAscii(
                        schema.getFieldName(fieldNumber),
                        this,
                        sink.writeByteArray(
                                COMMA_AND_QUOTE,
                                this,
                                tail)));
    }
Returns true if the last written field was a repeated field.
protostuff-json/src/main/java/io/protostuff/JsonXOutput.java