Supose I have a WCF service which sends List serialized with protobuf-net. That function returns byte[], application/octet-stream.
Now, in my java application I have compiled MyClass.proto into MyClass.java and get from http the data sent before.
To deserialize 1 object I shall use
MyClass MyObject = MyClass.parseFrom(http_input_stream);
But what shall I use if an array comes…?
A
List<MyClass>is actually serialized as a sequence ofMyClassobjects, each with a standard field-header of1. I don’t know the java API backwards: if it has a “read a sequence of items” API then: use that. However, a trusty fallback is the following, entirely compatible “.proto” fragment:Load the data as a
Foo(you might want to rename that…) and: job done.