![JAR search and dependency download from the Maven repository](/logo.png)
com.jingtum.net.PaymentChoiceCollectionDeserializer Maven / Gradle / Ivy
package com.jingtum.net;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import com.jingtum.model.PaymentChoice;
import com.jingtum.model.PaymentChoiceCollection;
import java.lang.reflect.Type;
import java.util.List;
public class PaymentChoiceCollectionDeserializer implements JsonDeserializer {
public PaymentChoiceCollection deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
Gson gson = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.create();
if (json.isJsonArray()) {
Type paymentchoiceListType = new TypeToken>() {
}.getType();
List choice = gson.fromJson(json, paymentchoiceListType);
PaymentChoiceCollection collection = new PaymentChoiceCollection();
collection.setData(choice);
return collection;
}
return gson.fromJson(json, typeOfT);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy