fix deserialize
This commit is contained in:
parent
21b36199a6
commit
73b4e9a2c9
@ -79,11 +79,20 @@ public class Aria2HttpProxy implements InvocationHandler {
|
||||
}
|
||||
|
||||
private Object deserialize(String json, Type resultType) {
|
||||
if (resultType.equals(String.class)) {
|
||||
return json;
|
||||
}
|
||||
JsonObject jsonObject = JsonParser.parseString(json).getAsJsonObject();
|
||||
JsonElement result = jsonObject.get("result");
|
||||
|
||||
if (Objects.isNull(result)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (resultType.equals(String.class)) {
|
||||
if (result.isJsonPrimitive()) {
|
||||
return result.getAsJsonPrimitive().getAsString();
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
return gson.fromJson(result, resultType);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user