diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-05-05 22:37:25 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-05-05 22:37:25 +0200 |
commit | fc1ee9bd5d09a6a932e62e8652a8dafed1515d09 (patch) | |
tree | 982832c6ec1299a63e1ebe83923f0ecc0e446f14 /src/main/kotlin | |
parent | b3475b4541c60545b32ac8e04d6d099f9edf5097 (diff) | |
download | kvision-fc1ee9bd5d09a6a932e62e8652a8dafed1515d09.tar.gz kvision-fc1ee9bd5d09a6a932e62e8652a8dafed1515d09.tar.bz2 kvision-fc1ee9bd5d09a6a932e62e8652a8dafed1515d09.zip |
Serialization fix for enums
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt b/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt index 4c6ecf82..151f84a2 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt @@ -337,11 +337,15 @@ open class RemoteAgent<out T>(val serviceManager: ServiceManager<T>) { if (serializer != null) { JSON.stringify(serializer, it) } else { - try { - @Suppress("UNCHECKED_CAST") - JSON.stringify((PAR::class as KClass<Any>).serializer(), it as Any) - } catch (e: Throwable) { - it.toString() + if (it is Enum<*>) { + "\"$it\"" + } else { + try { + @Suppress("UNCHECKED_CAST") + JSON.stringify((PAR::class as KClass<Any>).serializer(), it as Any) + } catch (e: Throwable) { + it.toString() + } } } } |