From fc1ee9bd5d09a6a932e62e8652a8dafed1515d09 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 5 May 2018 22:37:25 +0200 Subject: Serialization fix for enums --- src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt') 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(val serviceManager: ServiceManager) { if (serializer != null) { JSON.stringify(serializer, it) } else { - try { - @Suppress("UNCHECKED_CAST") - JSON.stringify((PAR::class as KClass).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).serializer(), it as Any) + } catch (e: Throwable) { + it.toString() + } } } } -- cgit