aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-02-13 13:42:22 +0100
committerRobert Jaros <rjaros@finn.pl>2019-02-13 13:42:22 +0100
commit8beb2bcc4806a69dc99acdd706f7de94bbe35955 (patch)
treec3d78714cd4982943472fcd7e878efe23bea238b /kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision
parentae28bdd65cbc56b10d36d33a9090ee31ca96908e (diff)
downloadkvision-8beb2bcc4806a69dc99acdd706f7de94bbe35955.tar.gz
kvision-8beb2bcc4806a69dc99acdd706f7de94bbe35955.tar.bz2
kvision-8beb2bcc4806a69dc99acdd706f7de94bbe35955.zip
Unification of @Serializable -> JSON functions
Diffstat (limited to 'kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision')
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt11
1 files changed, 3 insertions, 8 deletions
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
index 1ec5610a..e15e43cb 100644
--- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
@@ -25,18 +25,15 @@ import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.DynamicObjectParser
import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.SerializationStrategy
-import kotlinx.serialization.json.Json
import kotlinx.serialization.serializer
import kotlinx.serialization.stringify
import pl.treksoft.jquery.JQueryAjaxSettings
import pl.treksoft.jquery.JQueryXHR
import pl.treksoft.jquery.jQuery
import pl.treksoft.kvision.utils.JSON
+import pl.treksoft.kvision.utils.JSON.toObj
import pl.treksoft.kvision.utils.obj
import kotlin.js.Promise
-import kotlin.js.then
-import kotlin.js.undefined
-import kotlin.js.JSON as NativeJSON
/**
* HTTP status unauthorized (401).
@@ -193,8 +190,7 @@ open class CallAgent {
contentType: String = "application/json",
beforeSend: ((JQueryXHR, JQueryAjaxSettings) -> Boolean)? = null
): Promise<dynamic> {
- val dynamicData = NativeJSON.parse<dynamic>(Json.stringify(serializer, data))
- return remoteCall(url, dynamicData, method, contentType, beforeSend)
+ return remoteCall(url, data.toObj(serializer), method, contentType, beforeSend)
}
@@ -220,8 +216,7 @@ open class CallAgent {
beforeSend: ((JQueryXHR, JQueryAjaxSettings) -> Boolean)? = null,
transform: ((dynamic) -> dynamic)? = null
): Promise<T> {
- val dynamicData = NativeJSON.parse<dynamic>(Json.stringify(serializer, data))
- return remoteCall(url, dynamicData, method, contentType, beforeSend).then { result: dynamic ->
+ return remoteCall(url, data.toObj(serializer), method, contentType, beforeSend).then { result: dynamic ->
val transformed = if (transform != null) {
transform(result)
} else {