[protobuf] [De]serialization of messages to java strings
Hello all; I need to serialize a protobuf message to a string so that it can be passed outside my program. The below fails, I'm guessing due to UTF8 encoding issues: byte[] arr = msg.toByteArray(); String str = new String(arr); // ... pass str around ... MsgType msg2 = MsgType.parseFrom(str.getBytes()); // -- throws InvalidProtocolBufferException So, reading the API, I thought I should use ByteStrings, with their handy UTF8 encoding methods, but this doesn't work either: ByteString bs = msg.toByteString(); String str = bs.toStringUtf8(); // ... pass str around ... ByteString bs2 = ByteString.copyFromUtf8(str); MsgType msg2 = MsgType.parseFrom(bs2); // -- Still throws exception What am I doing wrong? What's the best way to do java string serialization of protobuf messages? Thanks in advance, Will -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@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.
Re: [protobuf] [De]serialization of messages to java strings
2009/11/25 Adam Vartanian flo...@google.com: What am I doing wrong? What's the best way to do java string serialization of protobuf messages? If you absolutely have to pass things around as a String, you're going to need to do so in some kind of encoding that supports arbitrary data. For example, you could encode it in Base64. Great, thanks guys... I was wondering if protobuf had a more efficient string-safe encoding, but I'll just base64 it. Cheers! Will -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to proto...@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.
[protobuf] Re: Any type with python
I found the source code that Jie linked to, however, it's not clear how to initialize an Any object. Can someone provide an example of how best to do so? On Friday, February 26, 2016 at 11:44:52 AM UTC-5, Tim Richardson wrote: > > Is the Any type implemented in the python libraries yet? > > I read this on the documentation > > *Currently the runtime libraries for working with Any types are under > development*. > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] Protobuf and Schema Registry
m conducting an investigation into the use of Protobuf for my organization and have a need to perform schema discovery. I've seen a number of articles related to Confluent Schema Registry with Avro. What are folks using for Protobuf? -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.