public static <T> void writeListTo(OutputStream out, List<T> messages, Schema<T> schema,
            boolean numeric, LinkedBuffer buffer) throws IOException
    {
        if (buffer.start != buffer.offset)
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");

        if (messages.isEmpty())
        {
            System.arraycopy(EMPTY_ARRAY, 0, buffer.buffer, buffer.offset, EMPTY_ARRAY.length);
            buffer.offset += EMPTY_ARRAY.length;
            return;
        }

        final JsonXOutput output = new JsonXOutput(buffer, out, numeric, schema);

        output.writeStartArray();

        boolean first = true;
        for (T m : messages)
        {
            if (first)
            {
                first = false;
                output.writeStartObject();
            }
            else
                output.writeCommaAndStartObject();

            schema.writeTo(output, m);
            if (output.isLastRepeated())
                output.writeEndArray();

            output.writeEndObject().reset();
        }

        output.writeEndArray();
        LinkedBuffer.writeTo(out, buffer);
    }
Serializes the {@code messages} into the stream using the given schema with the supplied buffer.
protostuff-json/src/main/java/io/protostuff/JsonXIOUtil.java