xiehuachun / protobuf-java-format

Automatically exported from code.google.com/p/protobuf-java-format
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

JsonFormat: add method for serializing collection of messages #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a collection of Message instances
2. Use JsonFormat to serialize them

What is the expected output? What do you see instead?

The expected output is an array of Messages:
[ {"name":"msg1"}, {"name":"msg2"}, {"name":"msg3"} ]

Since there is no support for serializing a collection of Message
instances, the calling code needs to "manually" open and close the array
brakets.

Ideally, the calling code would call a method with the following signature:

JsonFormat.print(Iterable<Message> messages, Appendable a);

What version of the product are you using? On what operating system?
1.1

Please provide any additional information below.

Or is the pattern to create a Message type that has a repeatable field of
other Message types?

message Foo {
  required string name = 1;
}

message Foos {
  repeatable Foo foos = 1;
}

Original issue reported on code.google.com by philippe...@gmail.com on 13 May 2010 at 9:38

GoogleCodeExporter commented 9 years ago
Based on an identical issue discussed over protobuf group, the only solution 
for this 
is to create a message containing repeated field of the original message (like 
the 
example you provided)

Original comment by eliran.bivas on 25 May 2010 at 12:58