diff --git a/rxhttp-converter/converter-serialization/src/main/java/rxhttp/wrapper/converter/SerializationConverter.kt b/rxhttp-converter/converter-serialization/src/main/java/rxhttp/wrapper/converter/SerializationConverter.kt index 7a9d34d7..b8a9ad36 100644 --- a/rxhttp-converter/converter-serialization/src/main/java/rxhttp/wrapper/converter/SerializationConverter.kt +++ b/rxhttp-converter/converter-serialization/src/main/java/rxhttp/wrapper/converter/SerializationConverter.kt @@ -28,9 +28,6 @@ class SerializationConverter( if (needDecodeResult) { json = RxHttpPlugins.onResultDecoder(json) } - if (type == String::class.java) { - return json as T - } val serializer = format.serializersModule.serializer(type) return format.decodeFromString(serializer, json) as T } diff --git a/rxhttp/src/main/java/rxhttp/wrapper/converter/GsonConverter.java b/rxhttp/src/main/java/rxhttp/wrapper/converter/GsonConverter.java index 309a8ea7..60849ff8 100644 --- a/rxhttp/src/main/java/rxhttp/wrapper/converter/GsonConverter.java +++ b/rxhttp/src/main/java/rxhttp/wrapper/converter/GsonConverter.java @@ -52,16 +52,17 @@ public static GsonConverter create(Gson gson, MediaType contentType) { } @NotNull - @SuppressWarnings("unchecked") @Override public T convert(@NotNull ResponseBody body, @NotNull Type type, boolean needDecodeResult) throws IOException { try { - String result = body.string(); + T t; if (needDecodeResult) { + String result = body.string(); result = RxHttpPlugins.onResultDecoder(result); + t = gson.fromJson(result, type); + } else { + t = gson.fromJson(body.charStream(), type); } - if (type == String.class) return (T) result; - T t = gson.fromJson(result, type); if (t == null) { throw new IllegalStateException("GsonConverter Could not deserialize body as " + type); }