public static Object deserialize(String json, String containerType, Class cls) throws ApiException { try { if ("list".equalsIgnoreCase(containerType) || "array".equalsIgnoreCase(containerType)) { return JsonUtil.deserializeToList(json, cls); } else if (String.class.equals(cls)) { if (json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1) return json.substring(1, json.length() - 1); else return json; } else { return JsonUtil.deserializeToObject(json, cls); } } catch (JsonParseException e) { throw new ApiException(500, e.getMessage()); } }