diff --git a/launcher/src/main/java/com/skcraft/launcher/util/HttpRequest.java b/launcher/src/main/java/com/skcraft/launcher/util/HttpRequest.java index cc23121..29a1704 100644 --- a/launcher/src/main/java/com/skcraft/launcher/util/HttpRequest.java +++ b/launcher/src/main/java/com/skcraft/launcher/util/HttpRequest.java @@ -6,6 +6,7 @@ package com.skcraft.launcher.util; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.skcraft.concurrency.ProgressObservable; import lombok.Getter; @@ -452,6 +453,7 @@ public class HttpRequest implements Closeable, ProgressObservable { * Return the result as an instance of the given class that has been * deserialized from a JSON payload. * + * @param cls the class * @return the object * @throws java.io.IOException on I/O error */ @@ -459,6 +461,18 @@ public class HttpRequest implements Closeable, ProgressObservable { return mapper.readValue(asString("UTF-8"), cls); } + /** + * Return the result as an instance of the given type that has been + * deserialized from a JSON payload. + * + * @param type the type reference + * @return the object + * @throws java.io.IOException on I/O error + */ + public T asJson(TypeReference type) throws IOException { + return mapper.readValue(asString("UTF-8"), type); + } + /** * Return the result as an instance of the given class that has been * deserialized from a XML payload.