aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/rest
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-11-04 11:26:12 +0100
committerRobert Jaros <rjaros@finn.pl>2019-11-04 11:26:12 +0100
commite94718175bbe0436306d7c4c988d24d5c2196e82 (patch)
tree53ddf6f23c7234d1d00b34aa8ea7b34a3825e071 /src/main/kotlin/pl/treksoft/kvision/rest
parentafb2bf0b4fb0446a6bc427e8ee31cbd56b23d052 (diff)
downloadkvision-e94718175bbe0436306d7c4c988d24d5c2196e82.tar.gz
kvision-e94718175bbe0436306d7c4c988d24d5c2196e82.tar.bz2
kvision-e94718175bbe0436306d7c4c988d24d5c2196e82.zip
Support for Date type serialization/deserialization in RestClient (#101)
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/rest')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/rest/RestClient.kt27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/rest/RestClient.kt b/src/main/kotlin/pl/treksoft/kvision/rest/RestClient.kt
index 49222298..b2aae632 100644
--- a/src/main/kotlin/pl/treksoft/kvision/rest/RestClient.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/rest/RestClient.kt
@@ -25,12 +25,15 @@ import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.DynamicObjectParser
import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.SerializationStrategy
+import kotlinx.serialization.modules.serializersModuleOf
import kotlinx.serialization.serializer
import pl.treksoft.jquery.JQueryAjaxSettings
import pl.treksoft.jquery.JQueryXHR
import pl.treksoft.jquery.jQuery
+import pl.treksoft.kvision.types.DateSerializer
import pl.treksoft.kvision.utils.JSON.toObj
import pl.treksoft.kvision.utils.obj
+import kotlin.js.Date
import kotlin.js.Promise
import kotlin.js.JSON as NativeJSON
@@ -103,7 +106,10 @@ open class RestClient {
} else {
result
}
- DynamicObjectParser().parse(transformed, deserializer)
+ DynamicObjectParser(context = serializersModuleOf(Date::class, DateSerializer)).parse(
+ transformed,
+ deserializer
+ )
}
}
@@ -157,7 +163,10 @@ open class RestClient {
} else {
result
}
- DynamicObjectParser().parse(transformed, deserializer)
+ DynamicObjectParser(context = serializersModuleOf(Date::class, DateSerializer)).parse(
+ transformed,
+ deserializer
+ )
}
}
@@ -381,7 +390,12 @@ open class RestClient {
} else {
result.data
}
- Response(DynamicObjectParser().parse(transformed, deserializer), result.textStatus, result.jqXHR)
+ Response(
+ DynamicObjectParser(context = serializersModuleOf(Date::class, DateSerializer)).parse(
+ transformed,
+ deserializer
+ ), result.textStatus, result.jqXHR
+ )
}
}
@@ -441,7 +455,12 @@ open class RestClient {
} else {
result.data
}
- Response(DynamicObjectParser().parse(transformed, deserializer), result.textStatus, result.jqXHR)
+ Response(
+ DynamicObjectParser(context = serializersModuleOf(Date::class, DateSerializer)).parse(
+ transformed,
+ deserializer
+ ), result.textStatus, result.jqXHR
+ )
}
}