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

        if (lastNumber != fieldNumber)
        {
            if (lastRepeated)
                generator.writeEndArray();

            final String name = numeric ? Integer.toString(fieldNumber) :
                    lastSchema.getFieldName(fieldNumber);

            if (repeated)
                generator.writeArrayFieldStart(name);
            else
                generator.writeFieldName(name);
        }

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

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

        if (lastRepeated)
            generator.writeEndArray();

        generator.writeEndObject();

        // 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/JsonOutput.java