Search in sources :

Example 1 with ListingResponseData

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

the class ListingResponseDeserializer method deserialize.

@Override
public ListingResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    // If no object is returned, return null
    if (json.isJsonPrimitive()) {
        return null;
    }
    JsonObject obj = json.getAsJsonObject();
    String kind = obj.get("kind").getAsString();
    ListingResponseData data = context.deserialize(obj.get("data"), ListingResponseData.class);
    ListingResponse response = new ListingResponse();
    response.setKind(kind);
    response.setData(data);
    return response;
}
Also used : JsonObject(com.google.gson.JsonObject) ListingResponse(rxreddit.model.ListingResponse) ListingResponseData(rxreddit.model.ListingResponseData)

Aggregations

JsonObject (com.google.gson.JsonObject)1 ListingResponse (rxreddit.model.ListingResponse)1 ListingResponseData (rxreddit.model.ListingResponseData)1