Search in sources :

Example 1 with ModReport

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

the class ModReportDeserializer method deserialize.

@Override
public ModReport 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 username element
    String username = array.get(1).getAsString();
    return new ModReport(text, username);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) ModReport(rxreddit.model.ModReport) JsonNull(com.google.gson.JsonNull)

Aggregations

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