To print Any in JSON, you need to provide a TypeRegistry including the descriptor of all types that may be included in the Any field. See an example here: https://github.com/google/protobuf/blob/master/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java#L811
On Thu, Jan 12, 2017 at 9:01 AM, Michael Lindenmayer < [email protected]> wrote: > I am having some trouble creating a message and printing it to JSON using > the any type. Below is the code that is run: > > > Any any = Any.pack(myMessage); > > String jsonFormat = JsonFormat.printer().print(any); > > This thrown an exception: Cannot find type for url: > type.googleapis.com/org.apache.activemq.recipies.messages.MyMessage > > I feel like the mistake is simple, but I can't seem to figure it out. > > Any help would be appreciated!!! > > Michael > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
