Protobuf binary<->JSON serialization option / alternatives?

1.3k views Asked by At

I've been investigating about protobuf/gRPC. I really like the idea of being able to use a common *proto file as IDL to centralize the definition of structs and services, as well as all the existing tooling around it to create common code for clients and servers (gRPC plugin) in different programming languages.

What I don't really like is that if forces a binary serialization format. I would like protobuf to have the option to switch between JSON or binary format.

I'm wondering what alternatives (if any) provide the advantages of protobuf/gRPC (many languages, IDL, template code for client and servers) while still allowing for JSON encoding.

Is it possible that protobuf already allows for JSON through some feature I'm not aware of?

2

There are 2 answers

0
kliew On

Protobuf does not support this. In Java, you can use Google's gson library for json which uses reflection to convert arbitrary objects to json based on the member variable names.

0
Adam Cozzette On