@Override public JsonRpcResponse deserialize( JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String id = jsonObject.get(ResponseProperty.ID.key()).getAsString(); if (jsonObject.has(ResponseProperty.ERROR.key())) { JsonElement errorObject = jsonObject.get(ResponseProperty.ERROR.key()); String errorMessage = errorObject.getAsJsonObject().get("message").getAsString(); return JsonRpcResponse.error(id, errorMessage); } // Deserialize the data. Map<ParamsProperty, Object> properties = new HashMap<ParamsProperty, Object>(); JsonElement data = jsonObject.get(ResponseProperty.DATA.key()); if (data != null && data.isJsonObject()) { for (Entry<String, JsonElement> parameter : data.getAsJsonObject().entrySet()) { ParamsProperty parameterType = ParamsProperty.fromKey(parameter.getKey()); if (parameterType == null) { // Skip this unknown parameter. continue; } Object object = null; if (parameterType == ParamsProperty.BLIPS) { Type blipMapType = new TypeToken<Map<String, BlipData>>() {}.getType(); object = context.deserialize(parameter.getValue(), blipMapType); } else { object = context.deserialize(parameter.getValue(), parameterType.clazz()); } properties.put(parameterType, object); } } return JsonRpcResponse.result(id, properties); }