Search in sources :

Example 1 with UserReport

use of rxreddit.model.UserReport in project RxReddit by damien5314.

the class UserReportDeserializer method deserialize.

@Override
public UserReport deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    JsonArray array = json.getAsJsonArray();
    // Extract text element
    JsonElement textElement = array.get(0);
    String text = textElement instanceof JsonNull ? null : textElement.getAsString();
    // Extract quantity element
    int quantity = array.get(1).getAsInt();
    return new UserReport(text, quantity);
}
Also used : JsonArray(com.google.gson.JsonArray) UserReport(rxreddit.model.UserReport) JsonElement(com.google.gson.JsonElement) JsonNull(com.google.gson.JsonNull)

Aggregations

JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonNull (com.google.gson.JsonNull)1 UserReport (rxreddit.model.UserReport)1