Re: [protobuf] Can you use protobuf to map json messages formatted differently to the same buffer?

10 views
Skip to first unread message

Adam Cozzette

unread,
Aug 15, 2019, 8:41:34 PM8/15/19
to Ma N, Protocol Buffers
No, unfortunately I don't think that is supported. You can set the json_name field option in your .proto file to specify the field name to be used for JSON, but you can't specify more than one name for a field.

On Wed, Aug 14, 2019 at 4:00 PM Ma N <mahmoud.a...@gmail.com> wrote:
let's say 2 jsons have different keys but map to the same key in the buffer, for example:

{
 keyA
:1,
 keyB
:5
}

should map to a buffer containing: 

{ quantity: 1, cost: 5 }

and:

{
 keyC
:5,
 keyD
:10
}

should map to a buffer containing:

{ quantity: 5, cost: 10 }

as you can see both "KeyA", "KeyC" map to quantity and "KeyB", "KeyD" to "cost".

How can we do that with protobuf?

Thank you!

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/67303340-2961-499e-af60-e9c3cef371fb%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages