@Override
    public <T> void writeObject(final int fieldNumber, final T value, final Schema<T> schema,
            final boolean repeated) throws IOException
    {
        final WriteSink sink = this.sink;
        final Schema<?> lastSchema = this.schema;

        if (lastNumber == fieldNumber)
        {
            tail = sink.writeByteArray(
                    COMMA_AND_START_OBJECT,
                    this,
                    tail);
        }
        else
        {
            tail = writeKey(
                    fieldNumber,
                    sink,
                    repeated ? KEY_SUFFIX_ARRAY_OBJECT : KEY_SUFFIX_OBJECT);
        }

        // reset
        this.schema = schema;
        lastNumber = 0;
        lastRepeated = false;

        // recursive write
        schema.writeTo(this, value);

        tail = lastRepeated ? sink.writeByteArray(END_ARRAY_AND_END_OBJECT, this, tail) :
                sink.writeByte(END_OBJECT, this, tail);

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