On Tue, Dec 20, 2016 at 6:17 AM, Qian Zhang <zhq527...@gmail.com> wrote:

> Hi,
>
> We are using protobuf 2.6.1 (C++) and there is a JSON like below that we'd
> like to parse:
> {
>   ...
>   "labels": {
>     "key1": "value1",
>     "key2": "value2"
>   }
> }
>
> So it is a string-string map, I know protobuf 2.6.1 does not support the
> "map" keyword, and I thought the backwards compatible way suggested here
> <https://developers.google.com/protocol-buffers/docs/proto#maps> should
> work, but after trying it, it seems not working. What I did is:
> message Labels {
>   message Entry {
>     required string key = 1;
>     required string value = 2;
>   }
>
>   repeated Entry entries = 1;
> }
>
> message xxx {
>   ...
>   required Labels labels = 8;
> }
>
> After calling protobuf to parse that JSON, I found there is nothing in
> "xxx.labels.entries". Can you please let me know any issues in my way
> above? Or with protobuf 2.6.1, I have to parse "map" manually?
>
protobuf 2.6.1 doesn't support JSON. What's the JSON library you are using?
This I think requires special handling in the JSON library you are using to
transform a JSON object to a repeated field in protobuf.


>
>
> Qian
> Thanks!
>
> --
> 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.

Reply via email to