From ae50b4346134d1f2cb0f740559496ca1d05e091d Mon Sep 17 00:00:00 2001 From: ahmed smiai Date: Wed, 13 Sep 2023 15:37:10 +0100 Subject: [PATCH] added fromJsonString fun --- src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt b/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt index b950bf9f..a9f8d61b 100644 --- a/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt +++ b/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt @@ -14,6 +14,7 @@ import id.walt.rest.OpenAPIUtils.documentedIgnored import io.javalin.Javalin import io.javalin.apibuilder.ApiBuilder.* import io.javalin.core.util.RouteOverviewPlugin +import io.javalin.plugin.json.JavalinJackson import io.javalin.plugin.json.JsonMapper import io.javalin.plugin.openapi.InitialConfigurationCreator import io.javalin.plugin.openapi.OpenApiOptions @@ -104,6 +105,10 @@ object NftKitApi { override fun toJsonString(obj: Any): String { return Klaxon().toJsonString(obj) } + override fun fromJsonString(json: String, targetClass: Class): T & Any { + return JavalinJackson(mapper).fromJsonString(json, targetClass)!! + } + /*override fun fromJsonStream(json: InputStream, targetClass: Class): T & Any { return JavalinJackson(mapper).fromJsonString(json, targetClass)