My problem is to serialize protobuf data in C++ and deserialize the
data in Java probably. In fact I get **InvalidProtobufferException**
in Java.

Here is my minimal example:

My protobuf file looks like this:

    option java_outer_classname = "NameProtos";

    message Name {

       required string name = 1;
    }

Which I compile with:

    protoc -I=. --cpp_out=../cpp/ name.proto

 and

    protoc -I=. --java_out=../java/ name.proto


In C++ I create the name object this way:

    Name name;
    name.set_name("platzhirsch");
    socket.send(name.SerializeAsString);

In Java I read from the socket, until the socket is closed
(socket.send closes the connection, after it entirely wrote the string
passed, so I guess here is no when stop reading issue, isn't there?).

In Java I make the following call in order to deserialize:

`NameProtos.Name name =
NameProtos.Name.parseFrom(ByteString.copyFromUtf8(received))`;

However I always get **InvalidProtocolBufferException**

I have no idea, the received strings are not empty though, they look
like this:
[SPACE]platzhirsch[A Character which cannot be displayed probably]

These character which I cannot read, I also get, when using other
fields like int32. I guess there are just encoded into the string.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to