Now that we are using AutoValue, the response objects which get created during the serialization of JSON require a type adapter factory which can often be confusing in times when you want to deserialize a JSON string into a DirectionsResponse for example. Doing so without adding the type adapter factory will result in:
Failed to invoke public com.mapbox.directions.v5.models.DirectionsRoute() with no args
To make this easier, I'm proposing we add a static factory method to all API model classes which would looks something like:
public static DirectionsResponse fromJson(String json) {
return GsonBuilder().registerTypeAdapterFactory(DirectionsAdapterFactory.create()).create()
.fromJson(directionsRoute, DirectionsResponse.class);
}
cc: @zugaldia
Now that we are using AutoValue, the response objects which get created during the serialization of JSON require a type adapter factory which can often be confusing in times when you want to deserialize a JSON string into a DirectionsResponse for example. Doing so without adding the type adapter factory will result in:
To make this easier, I'm proposing we add a static factory method to all API model classes which would looks something like:
cc: @zugaldia