use of com.google.cloud.retail.v2.Product.Type in project java-retail by googleapis.
the class SetupCleanup method getGson.
public static Gson getGson() {
JsonDeserializer<LegacySQLTypeName> typeDeserializer = (jsonElement, type, deserializationContext) -> {
return LegacySQLTypeName.valueOf(jsonElement.getAsString());
};
JsonDeserializer<FieldList> subFieldsDeserializer = (jsonElement, type, deserializationContext) -> {
Field[] fields = deserializationContext.deserialize(jsonElement.getAsJsonArray(), Field[].class);
return FieldList.of(fields);
};
return new GsonBuilder().registerTypeAdapter(LegacySQLTypeName.class, typeDeserializer).registerTypeAdapter(FieldList.class, subFieldsDeserializer).create();
}
Aggregations