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