Hi Tim,

I think your analysis is correct. The answer to your question is that it's 
not possible to transcode Any from JSON <-> protobuf unless you have the 
schema. That is one of the reasons why the type URL exists as a way to 
fetch schemas for types you otherwise wouldn't know about.

I'm glad the conformance suite was helpful!

Best,
Josh

On Wednesday, February 3, 2016 at 1:37:40 PM UTC-8, Tim Kientzle wrote:
>
> I’m trying to implement Any, including proper JSON and protobuf encoding, 
> and the following scenario has me stumped:
>
>
> I’m looking at the any.proto file, which includes this example:
>
>
> Sample proto file:
>
> //     package google.profile;
>
> //     message Person {
>
> //       string first_name = 1;
>
> //       string last_name = 2;
>
> //     }
>
>
> Resulting JSON encoding:
>
> //     {
>
> //       "@type": "type.googleapis.com/google.profile.Person",
>
> //       "firstName": <string>,
>
> //       "lastName": <string>
>
> //     }
>
>
> The scenario I’m trying to understand involves three systems:
>
>
> Originating system:
>
> * Knows google.profile and writes out the JSON above
>
>
> Middle system:
>
> * Reads the JSON example above
>
> * Does *not* know google.profile (doesn’t have the descriptor and has no 
> way to get it)
>
> * Writes out protobuf
>
>
> Receiving system:
>
> * Knows google.profile and reads the protobuf
>
>
> In particular:  What is the protobuf serialization between the middle and 
> receiving systems?
>
>
> Without the descriptor, the middle system cannot poduce the “real" 
> protobuf binary format (the field numbers aren’t in that format), so the 
> only option would seem to be to serialize the JSON data as a protobuf 
> Struct representation (which in turn has interesting implications for the 
> receiving system). Am I missing some other option?
>
>
> Tim
>
>
> P.S.  Nice work on the conformance test suite, by the way!  That clarified 
> a *lot* of details about the expected handling for protobuf JSON format.
>
>
>

-- 
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