Wire Type Adapter Factory
A TypeAdapterFactory that allows Wire messages to be serialized and deserialized using the GSON Json library. To create a Gson instance that works with Wire, use the com.google.gson.GsonBuilder interface:
Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(new WireTypeAdapterFactory())
.create();
The resulting Gson instance will be able to serialize and deserialize any Wire Message type, including extensions and unknown field values. The JSON encoding is intended to be compatible with the protobuf-java-format library. Note that version 1.2 of that API has a bug in the way it serializes unknown fields, so we use our own approach for this case.
In Proto3, if a field is set to its default (or identity) value, it will be omitted in the JSON-encoded data. Set writeIdentityValues to true if you want Wire to always write values, including default ones.