[protobuf] Deserializng JSON tagged unions?
I'm looking to generate de/serialization for json tagged union messages from an external rest api, eg. { type: "error", message: "wrong"} or { type:"ok", response: { a: 1, b: 2}}. Reading the docs it seems like an any valued field the type field modified json_name would work similarly, although this isn't supported. Is there an existing .proto message that would map to those messages? Perhaps with some annotation to this more obvious schema, or being able to specify a custom tag to determine which case of a oneof is in use (instead of the default enum value)? message Error { string message = 1; } message Second { int64 response = 1; } message MyUnion { oneof Either { Error err = 1; Ok ok = 2; } } -- 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.
Re: [protobuf] Deserializng JSON tagged unions?
That does work, but it seems like it creates a lot of unnecessary work if there are many fields. Is there a better way to handle a schema more like this? { type: "error", message: "wrong"} or { type:"ok", a: 1, b:2, c:3, d:4, ... }. On Monday, May 9, 2016 at 3:12:19 PM UTC-4, Feng Xiao wrote: > > > > On Fri, May 6, 2016 at 8:18 PM, Marco <a.f@gmail.com > > wrote: > >> I'm looking to generate de/serialization for json tagged union messages >> from an external rest api, eg. >> { type: "error", message: "wrong"} or { type:"ok", response: { a: 1, b: >> 2}}. >> >> Reading the docs it seems like an any valued field the type field >> modified json_name would work similarly, although this isn't supported. >> >> Is there an existing .proto message that would map to those messages? >> Perhaps >> with some annotation to this more obvious schema, or being able to specify >> a custom tag to determine which case of a oneof is in use (instead of the >> default enum value)? >> > How about something like: > > message Response { > string type = 1; > message Content { > int32 a = 1; > int32 b = 2; > } > oneof OneofResponse { > string message = 2; > Content response = 3; > } > } > > ? > > >> message Error { >> string message = 1; >> } >> >> message Second { >> int64 response = 1; >> } >> >> message MyUnion { >> oneof Either { >> Error err = 1; >> Ok ok = 2; >> } >> } >> >> >> >> >> -- >> 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+u...@googlegroups.com . >> To post to this group, send email to prot...@googlegroups.com >> . >> Visit this group at https://groups.google.com/group/protobuf. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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] protocol buffers and client-server communication
Hi all i am new to protocol buffer, and was wondering if i can use it for my needs. Basically, i am trying to implement a client-server communication where i can have this type of messages: - INCOMING (from client to server) - String - a Savings Object - a Share object - OUTCOMING (from server to client) - String - a List of Savings objects - a List of Share object Basically, what i am trying to say is that i have N types of messages from client to server and M types of messages from server to client, and all this messages are differents from each other (having in total N + M) types of messages. I am guessing i will need 1 proto file for each type of message, correct? w/kindest regards marco -- 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.
[protobuf] Problem when generating classes
Hi all i am starting to learn protobuffers so that i can use them alongside Netty I have created this simple .proto file package tutorial; option java_package = com.example.messages; option java_outer_classname = MessageProtos; message Message { required string content = 1; enum MessageType { TEST = 0; DEBUG = 1; DO_TASK = 2; } required MessageType type = 2; } THis has generated a class with two methods that Errors out due to 'Cannot dereference boolean' public static com.example.messages.MessageProtos.Message parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return newBuilder().mergeDelimitedFrom(input).buildParsed(); } public static com.example.messages.MessageProtos.Message parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return newBuilder().mergeDelimitedFrom(input, extensionRegistry) .buildParsed(); } could anyone tell me what have i done wrong in my .proto file? thanks and regards marco -- 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.
[protobuf] Re: Problem when generating classes
Hi ok i think i found the problem. I am compiling using protobuffer 2.2.0 , and in my project i am using libraries from protobuf 2.3.0 rgds marco On Jan 28, 11:45 pm, Marco@worldcorp mmistr...@gmail.com wrote: Hi all i am starting to learn protobuffers so that i can use them alongside Netty I have created this simple .proto file package tutorial; option java_package = com.example.messages; option java_outer_classname = MessageProtos; message Message { required string content = 1; enum MessageType { TEST = 0; DEBUG = 1; DO_TASK = 2; } required MessageType type = 2; } THis has generated a class with two methods that Errors out due to 'Cannot dereference boolean' public static com.example.messages.MessageProtos.Message parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return newBuilder().mergeDelimitedFrom(input).buildParsed(); } public static com.example.messages.MessageProtos.Message parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return newBuilder().mergeDelimitedFrom(input, extensionRegistry) .buildParsed(); } could anyone tell me what have i done wrong in my .proto file? thanks and regards marco -- 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.
[protobuf] why am i getting this exception?
HI all i have wrote a simple messages.proto, compiled it (On Ubuntu Lucid Lynx) with protobuf 2.2.0. here's the .proto file package tutorial; option java_package = com.example.messages; option java_outer_classname = MessageProtos; enum MessageType { TEST = 0; DEBUG = 1; DO_TASK = 2; } message Message { required string content = 1; optional MessageType type = 2; } I am using Netty as well, and when i run it i get the following exception 2011-01-29 11:05:30,708 [client.NettyEchoHandler ] ERROR * Unexpected exception from downstream. [New I/O client worker #1-1] com.google.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type. at com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java: 78) at com.google.protobuf.UnknownFieldSet $Builder.mergeFieldFrom(UnknownFieldSet.java:496) at com.google.protobuf.GeneratedMessage $Builder.parseUnknownField(GeneratedMessage.java:271) at com.example.messages.MessageProtos$Message $Builder.mergeFrom(MessageProtos.java:318) at com.example.messages.MessageProtos$Message $Builder.mergeFrom(MessageProtos.java:215) could anyone help pls? w/kindest regards marco -- 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.
[protobuf] Re: why am i getting this exception?
Hello, PLs ignore my message It was a Netty problem as i was using multiple decoders / encoders / frames and that was messing up the result sorry for bothering regards marco On Jan 29, 11:09 am, Marco@worldcorp mmistr...@gmail.com wrote: HI all i have wrote a simple messages.proto, compiled it (On Ubuntu Lucid Lynx) with protobuf 2.2.0. here's the .proto file package tutorial; option java_package = com.example.messages; option java_outer_classname = MessageProtos; enum MessageType { TEST = 0; DEBUG = 1; DO_TASK = 2; } message Message { required string content = 1; optional MessageType type = 2; } I am using Netty as well, and when i run it i get the following exception 2011-01-29 11:05:30,708 [client.NettyEchoHandler ] ERROR * Unexpected exception from downstream. [New I/O client worker #1-1] com.google.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type. at com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java: 78) at com.google.protobuf.UnknownFieldSet $Builder.mergeFieldFrom(UnknownFieldSet.java:496) at com.google.protobuf.GeneratedMessage $Builder.parseUnknownField(GeneratedMessage.java:271) at com.example.messages.MessageProtos$Message $Builder.mergeFrom(MessageProtos.java:318) at com.example.messages.MessageProtos$Message $Builder.mergeFrom(MessageProtos.java:215) could anyone help pls? w/kindest regards marco -- 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.
[protobuf] Error with Netty and extensions
Hi all i am trying to use extensions with protobuf and Netty here's my proto file package tutorial; option java_package = com.example.messages; option java_outer_classname = MessageProtos; option optimize_for = LITE_RUNTIME; enum MessageType { TEST = 0; DEBUG = 1; DO_TASK = 2; SPECIAL = 3; } message Message { required string content = 1; required MessageType type = 2; extensions 3 to 99; } extend Message { optional string enhancedContent = 3; optional Share share = 4; optional int32 bar = 5; } message Share { required string ticker = 10; required string company = 11; required double price = 12; } I am setting extensions this way in my client if(line.startsWith(task)) { builder.setType(MessageProtos.MessageType.DO_TASK); builder.setExtension(MessageProtos.bar, 1); } else { builder.setType(MessageProtos.MessageType.DEBUG); } I have written an unit test which works fine @Test public void testExtensions() throws Exception { MessageProtos.Message.Builder builder = MessageProtos.Message.newBuilder(); builder.setExtension(MessageProtos.bar, 1); builder.setContent(foobar); builder.setType(MessageProtos.MessageType.DEBUG); MessageProtos.Message message = builder.build(); Assert.assertTrue(message.hasExtension(MessageProtos.bar)); } However, on the serverside i am getting this exception 2011-02-06 20:44:58,130 [handlers.EchoServerHandler ] ERROR * Unexpected exception from downstream. [New I/O server worker #1-1] java.lang.NullPointerException at com.google.protobuf.GeneratedMessageLite $ExtendableBuilder.parseUnknownField(GeneratedMessageLite.java:311) at com.example.messages.MessageProtos$Message $Builder.mergeFrom(MessageProtos.java:273) at com.example.messages.MessageProtos$Message $Builder.mergeFrom(MessageProtos.java:187) at com.google.protobuf.AbstractMessageLite $Builder.mergeFrom(AbstractMessageLite.java:107) at com.google.protobuf.AbstractMessageLite $Builder.mergeFrom(AbstractMessageLite.java:161) at com.google.protobuf.AbstractMessageLite $Builder.mergeFrom(AbstractMessageLite.java:93) at org.jboss.netty.handler.codec.protobuf.ProtobufDecoder.decode(ProtobufDecoder.java: 103) at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java: 72) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java: 302) at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java: 317) at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java: 299) at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java: 216) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java: 274) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java: 261) at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:350) at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java: 281) at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:201) at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java: 46) at java.util.concurrent.ThreadPoolExecutor $Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor $Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Do i need to somehow declare extensions whenever i register my ProtocolDecoder / ProtocolEncoder? If i don't set any extensions, the client-server communication works fine could anyone help? w/kindest regards marco -- 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.
[protobuf] field of type timestamp or date with protobuf message
HI all is it possible to add a field of type timestamp , or date, to a protobuf message.. i have quickly read the guide, and i saw no trace of timestamps or fields of type date. could anyone assist? w/kindest regards marco -- 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.
[protobuf] XSD to define .proto format?
Hi all, Is there an XML schema (XSD) which defines the .proto file format? I need it so that JAXB can create the POJOs to fill a .proto file. Regards, Marco -- 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.
[protobuf] Numeric range not supported?
Hi all, I'm checking the protobuf language definition and I couldn't find anywhere support for numeric range. In XSD, for instance, one could have: simpleType name=ZeroToTen restriction base=int minInclusive value=0 / maxInclusive value=10 / /restriction /simpleType However I couldn't find equivalent translation in the proto language definition. I could find defaults and enums, but not number ranges. Regards, Marco -- 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.
[protobuf] Maps in protobuf / 2
HI all sorry i hijacked a previous thread .. Is it possibel to define Maps in protobuff? i have some serverside code which returns a MapString, Double, and i was wondering if there was a way in protobuf to define a Map could anyone help ? w/kindest regards marco -- 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.
[protobuf] Uploading the maven-protoc-plugin to Maven Central?
Hi all, Is there a reason why the plugin hasn't been uploaded to Maven Central? If you want I could take ownership of that but then I'd have to be the owner of the com.google.protobuf Maven groupId, which I don't think is a good idea. There are already two other maven-protoc-plugin out there, both custom and this is causing confusion. I believe people would like to see the Google maven-protoc-plugin and use that, but in a way is easy to use (e.g. available in Maven Central). -- 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.
RE: [protobuf] Uploading the maven-protoc-plugin to Maven Central?
So, the google maven-protoc plugin has been retired in favour of dtrott one. I had a look at dtrott plugin and it seems to me unnecessary convoluted. Additionally it runs under the BSD license, which is not very Enterprise Friendly. I created my own, which is just a wrapper around protoc and runs under the MIT license *and* is on Maven central: http://repo2.maven.org/maven2/uk/co/jemos/maven/plugins/maven-jemosProtoc-plugin/ Regards, Marco -Original Message- From: Gregory Kick [mailto:g...@google.com] Sent: 21 June 2011 18:26 To: Pherl Liu Cc: Marco Tedone; Protocol Buffers Subject: Re: [protobuf] Uploading the maven-protoc-plugin to Maven Central? See http://code.google.com/p/protobuf/issues/detail?id=81#c20 On Tue, Jun 21, 2011 at 4:23 AM, Pherl Liu liuj...@google.com wrote: +Gregory On Sun, Jun 19, 2011 at 4:16 PM, Marco Tedone marco.ted...@gmail.com wrote: Hi all, Is there a reason why the plugin hasn't been uploaded to Maven Central? If you want I could take ownership of that but then I'd have to be the owner of the com.google.protobuf Maven groupId, which I don't think is a good idea. There are already two other maven-protoc-plugin out there, both custom and this is causing confusion. I believe people would like to see the Google maven-protoc-plugin and use that, but in a way is easy to use (e.g. available in Maven Central). -- 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. -- Greg Kick Data Liberation -- 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.
RE: [protobuf] Uploading the maven-protoc-plugin to Maven Central?
I have already talked to dtrott and he confirmed his plugin runs under the BSD license. Time allowing I will attempt to contact him and suggest an official release. In the meantime I'm releasing version 0.0.2.RELEASE of my one. Regards, Marco -Original Message- From: Gregory Kick [mailto:g...@google.com] Sent: 21 June 2011 19:28 To: Marco Tedone Cc: Pherl Liu; Protocol Buffers Subject: Re: [protobuf] Uploading the maven-protoc-plugin to Maven Central? I can't seem to find anything about licenses in that code and IANAL anyway. That said, much of that code is derived from my original code, which was under the same license as protobuf anyway. Might be worth emailing him to make sure that the licensing is what you think it is. Anyway, I definitely support a community effort to build a better plugin. I'd suggest reaching out to dtrott and discussing collaboration and if you guys want to work on making some version of either plugin official then we can get CLAs for you guys and do that. On Tue, Jun 21, 2011 at 12:49 PM, Marco Tedone marco.ted...@gmail.com wrote: So, the google maven-protoc plugin has been retired in favour of dtrott one. I had a look at dtrott plugin and it seems to me unnecessary convoluted. Additionally it runs under the BSD license, which is not very Enterprise Friendly. I created my own, which is just a wrapper around protoc and runs under the MIT license *and* is on Maven central: http://repo2.maven.org/maven2/uk/co/jemos/maven/plugins/maven-jemosPro toc-plugin/ Regards, Marco -Original Message- From: Gregory Kick [mailto:g...@google.com] Sent: 21 June 2011 18:26 To: Pherl Liu Cc: Marco Tedone; Protocol Buffers Subject: Re: [protobuf] Uploading the maven-protoc-plugin to Maven Central? See http://code.google.com/p/protobuf/issues/detail?id=81#c20 On Tue, Jun 21, 2011 at 4:23 AM, Pherl Liu liuj...@google.com wrote: +Gregory On Sun, Jun 19, 2011 at 4:16 PM, Marco Tedone marco.ted...@gmail.com wrote: Hi all, Is there a reason why the plugin hasn't been uploaded to Maven Central? If you want I could take ownership of that but then I'd have to be the owner of the com.google.protobuf Maven groupId, which I don't think is a good idea. There are already two other maven-protoc-plugin out there, both custom and this is causing confusion. I believe people would like to see the Google maven-protoc-plugin and use that, but in a way is easy to use (e.g. available in Maven Central). -- 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. -- Greg Kick Data Liberation -- Greg Kick Data Liberation -- 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.
[protobuf] PROTOMAK 0.0.2.RELEASE just released
Hi, Protomak is a tool to auto-convert XSDs to .proto files. We have just released version 0.0.2.RELEASE. You can find out more at http://www.jemos.eu/projects/protomak Regards, Marco -- 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.
[protobuf] What causes TargetInvocationException during serialization
I am trying to serialize something like this (i'll summarize as the object is more complex): class Anag { } System.Reflection.TargetInvocationException was unhandled Message=TargetInvocationException StackTrace: at System.Reflection.RuntimePropertyInfo.GetValue() at ProtoBuf.Serializers.TupleSerializer.GetValue() at ProtoBuf.Serializers.TupleSerializer.Write() at ProtoBuf.Meta.RuntimeTypeModel.Serialize() at ProtoBuf.ProtoWriter.WriteObject() at ProtoBuf.Serializers.SubItemSerializer.ProtoBuf.Serializers.IProtoSerializer.Write() at ProtoBuf.Serializers.TagDecorator.Write() at ProtoBuf.Serializers.ListDecorator.Write() at ProtoBuf.Serializers.PropertyDecorator.Write() at ProtoBuf.Serializers.TypeSerializer.Write() at ProtoBuf.Meta.RuntimeTypeModel.Serialize() at ProtoBuf.Meta.TypeModel.SerializeCore() at ProtoBuf.Meta.TypeModel.Serialize() at ProtoBuf.Meta.TypeModel.Serialize() at ProtoBuf.Serializer.Serialize() [...] InnerException: -- 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 http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
Re: [protobuf] Deserializng JSON tagged unions?
Unnecessary being that deserialization ismore than a switch on the type. The Union approach also puts all the fields on one object, as opposed to separating by the type field - this is what I wanted to confirm as unsupported by protobuf. On Tue, May 10, 2016, 10:22 Tim Kientzle <t...@kientzle.com> wrote: > I’m not sure what you think is “unnecessary”. > > Are you trying to avoid actually declaring the types of a, b, c, d, etc? > > If so, you could use google.protobuf.Struct (which can parse a JSON object > in a generic way without requiring you to create a .proto at all) or any of > a number of other popular JSON parsing libraries. > > But if you want the type-safety that protobuf provides, then you have to > actually tell the protoc compiler the type of every field. In return, you > can skip a lot of checking in your code. > > Cheers, > > Tim > > > On May 10, 2016, at 7:08 AM, Marco <a.f.ma...@gmail.com> wrote: > > > > That does work, but it seems like it creates a lot of unnecessary work > if there are many fields. > > > > Is there a better way to handle a schema more like this? > > > > { type: "error", message: "wrong"} or { type:"ok", a: 1, b:2, c:3, d:4, > ... }. > > > > On Monday, May 9, 2016 at 3:12:19 PM UTC-4, Feng Xiao wrote: > > > > > > On Fri, May 6, 2016 at 8:18 PM, Marco <a.f@gmail.com> wrote: > > I'm looking to generate de/serialization for json tagged union messages > from an external rest api, eg. > > { type: "error", message: "wrong"} or { type:"ok", response: { a: 1, b: > 2}}. > > > > Reading the docs it seems like an any valued field the type field > modified json_name would work similarly, although this isn't supported. > > > > Is there an existing .proto message that would map to those messages? > Perhaps with some annotation to this more obvious schema, or being able to > specify a custom tag to determine which case of a oneof is in use (instead > of the default enum value)? > > How about something like: > > > > message Response { > > string type = 1; > > message Content { > > int32 a = 1; > > int32 b = 2; > > } > > oneof OneofResponse { > > string message = 2; > > Content response = 3; > > } > > } > > > > ? > > > > message Error { > > string message = 1; > > } > > > > message Second { > > int64 response = 1; > > } > > > > message MyUnion { > > oneof Either { > > Error err = 1; > > Ok ok = 2; > > } > > } > > > > > > > > > > -- > > 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+u...@googlegroups.com. > > To post to this group, send email to prot...@googlegroups.com. > > Visit this group at https://groups.google.com/group/protobuf. > > For more options, visit https://groups.google.com/d/optout. > > > > > > -- > > 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. > > -- 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.
Re: [protobuf] Issues in the proto 3 spec
Done :-) https://github.com/google/protobuf/issues/2424 -- 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.