mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-16 00:21:19 +00:00
Implementing gson in android client templates
This commit is contained in:
@@ -155,8 +155,7 @@ public class ApiInvoker {
|
||||
public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
|
||||
try{
|
||||
if("list".equalsIgnoreCase(containerType) || "array".equalsIgnoreCase(containerType)) {
|
||||
List response = (List<?>) JsonUtil.getGson().fromJson(json, cls);
|
||||
return response;
|
||||
return JsonUtil.deserializeToList(json, cls);
|
||||
}
|
||||
else if(String.class.equals(cls)) {
|
||||
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
|
||||
@@ -165,7 +164,7 @@ public class ApiInvoker {
|
||||
return json;
|
||||
}
|
||||
else {
|
||||
return JsonUtil.getGson().fromJson(json, cls);
|
||||
return JsonUtil.deserializeToObject(json, cls);
|
||||
}
|
||||
}
|
||||
catch (JsonParseException e) {
|
||||
@@ -176,7 +175,7 @@ public class ApiInvoker {
|
||||
public static String serialize(Object obj) throws ApiException {
|
||||
try {
|
||||
if (obj != null)
|
||||
return JsonUtil.getGson().toJson(obj);
|
||||
return JsonUtil.serialize(obj);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user