Re: [protobuf] Protocol message tag had invalid wire type.

2023-02-24 Thread ritesh singh
Ahh yes, thanks a lot. I was using wrong JsonFormat com.android.tools.idea.protobuf.util.JsonFormat On Saturday, February 25, 2023 at 3:47:43 AM UTC+5:30 Adam Cozzette wrote: > Once you have the DynamicMessage, you can use the JsonFormat API the same > way you would use it with ordinary message

Re: [protobuf] Protocol message tag had invalid wire type.

2023-02-24 Thread 'Adam Cozzette' via Protocol Buffers
Once you have the DynamicMessage, you can use the JsonFormat API the same way you would use it with ordinary messages. On Fri, Feb 24, 2023 at 1:52 PM ritesh singh wrote: > Thanks, any leads on generating json at run time using dynamicMessage. Any > existing api util if you can point me to. > >

Re: [protobuf] Protocol message tag had invalid wire type.

2023-02-24 Thread ritesh singh
Thanks, any leads on generating json at run time using dynamicMessage. Any existing api util if you can point me to. On Saturday, February 25, 2023 at 2:44:14 AM UTC+5:30 Adam Cozzette wrote: > I think DynamicMessage is the right approach since you need to work with > proto files that are only

Re: [protobuf] Protocol message tag had invalid wire type.

2023-02-24 Thread 'Adam Cozzette' via Protocol Buffers
I think DynamicMessage is the right approach since you need to work with proto files that are only known at run time. This will also allow you to generate JSON. On Fri, Feb 24, 2023 at 11:19 AM ritesh singh wrote: > > Or if there's a better different approach instead of relying on > FileDescript

Re: [protobuf] Protocol message tag had invalid wire type.

2023-02-24 Thread ritesh singh
Or if there's a better different approach instead of relying on FileDescriptorSet and DynamicMessage - considering i have access to only .pb (generate by proto-lite) or .proto file. On Saturday, February 25, 2023 at 12:46:44 AM UTC+5:30 ritesh singh wrote: > Thanks Adam, so basically i am writi

Re: [protobuf] Protocol message tag had invalid wire type.

2023-02-24 Thread ritesh singh
Thanks Adam, so basically i am writing an Intellij plugin for Android Studio. The plugin will just take the .pb file and .proto file, run the protoc compiler, generate FileDescriptorSet for proto and create a DynamicMessage using generated fileDescriptorSet and .pb. I was wondering if there a

Re: [protobuf] Protocol message tag had invalid wire type.

2023-02-24 Thread 'Adam Cozzette' via Protocol Buffers
A serialized protocol buffer doesn't include any type information, so before you can parse one you have to know in advance which type you're expecting. If you want to be prepared to accept either A or B, then a good solution is to put both types inside a oneof in a parent message, and then just par

Re: [protobuf] Protocol message tag had invalid wire type.

2023-02-23 Thread ritesh singh
Also does it matter if .pb was created using proto lite and android end. I believe the lite version doesn't store fields, so converting it to json using proto-util won't work and i need to make use of reflection. On Fri, 24 Feb, 2023, 6:54 am ritesh singh, wrote: > Thanks Adam. I will give it a

Re: [protobuf] Protocol message tag had invalid wire type.

2023-02-23 Thread ritesh singh
Thanks Adam. I will give it a shot. I thought of using *protoc* compiler, but what if my proto file contains nested messages *message A { B b = 1}* *message B {* *}* After running *protoc *on the proto file, it will generate 2 java classes. I won't know which generated class to use agains

Re: [protobuf] Protocol message tag had invalid wire type.

2023-02-23 Thread 'Adam Cozzette' via Protocol Buffers
I suspect that your code is getting an error because it's trying to parse a .proto file as a serialized protocol buffer. (This won't work since .proto files use a text representation very different from the standard protobuf binary format.) Probably the best way to fix this problem would be to invo

[protobuf] Protocol message tag had invalid wire type.

2023-02-23 Thread ritesh singh
Hello, I am working on creating a Android Studio plugin for proto data store. Android uses proto-lite, my current approach, i get the .pb file and .proto file and use the same in intellij plugin to deserialise it. *val psiFile = PsiManager.getInstance(project).findFile(protoFile) val