fix deserialize

This commit is contained in:
NikoXu 2025-02-14 09:36:14 +00:00
parent 21b36199a6
commit 73b4e9a2c9

View File

@ -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);
}