I have an Api that returns JSON. The response is in some format that can fit into an object called ApiResult and contains a Context andContext <T> and an int Code.
ApiResult is declared in a generic way, e.g. ApiResultApiResult<SomeObject>
I would like to know how to get GSON to convert the incoming JSON String to ApiResultApiResult<T>
So far I have:
Type apiResultType = new TypeToken<ApiResult<T>>() { }.getType(); ApiResult<T> result = gson.fromJson(json, apiResultType); But this still returns converts the Context to a LinkedHashMap instead (which I assume its what GSON falls back to)