vonox7
08/23/2021, 5:08 PMT
is an Enum? I’m really afraid to write code like T::class.js.toString().contains("Enum.call(this")
, although this works for the legacy compiler (Enum.call(this);
) and for the IR compiler (Enum.call(this, name, ordinal);
)
Question on StackOverflowturansky
08/23/2021, 6:11 PMvonox7
08/23/2021, 6:47 PMandylamax
08/23/2021, 7:01 PMturansky
08/23/2021, 7:05 PMvonox7
08/23/2021, 8:45 PMenum class EnumValue { OK, FAIL }
fun main() {
val client = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer()
}
}
GlobalScope.launch {
console.log(client.get<EnumValue>("<https://enhfqc4t7bqezvq.m.pipedream.net>"))
}
}
it fails with
"NoTransformationFoundException: No transformation found: class ByteChannelJS -> class EnumValue
with response from <https://enhfqc4t7bqezvq.m.pipedream.net/>:
status: 200
response headers:
content-length: 2
, content-type: text/html; charset=utf-8
at Object.captureStack (webpack-internal:///./kotlin-dce-dev/kotlin.js:38592:15)
at NoTransformationFoundException.Exception [as constructor] (webpack-internal:///./kotlin-dce-dev/kotlin.js:38925:14)
at NoTransformationFoundException.RuntimeException [as constructor] (webpack-internal:///./kotlin-dce-dev/kotlin.js:38951:17)
at NoTransformationFoundException.UnsupportedOperationException [as constructor] (webpack-internal:///./kotlin-dce-dev/kotlin.js:39041:24)
at UnsupportedOperationException_init (webpack-internal:///./kotlin-dce-dev/kotlin.js:39047:37)
at new NoTransformationFoundException (webpack-internal:///./kotlin-dce-dev/ktor-ktor-client-core-js-legacy.js:1243:5)
at Coroutine$receive_qi9ur9$.doResume (webpack-internal:///./kotlin-dce-dev/ktor-ktor-client-core-js-legacy.js:912:17)
at HttpClientCall_0.receive_qi9ur9$ (webpack-internal:///./kotlin-dce-dev/ktor-ktor-client-core-js-legacy.js:949:21)
at Coroutine$main$lambda.doResume (webpack-internal:///./kotlin-dce-dev/untitled.js:160:36)
at Coroutine$execute_s9rlw$.CoroutineImpl.resumeWith_tl1gpc$ (webpack-internal:///./kotlin-dce-dev/kotlin.js:38763:35)"
turansky
08/23/2021, 8:50 PMEnumValue
must have @Serializable
annotation in your examplevonox7
08/23/2021, 8:52 PMvonox7
08/23/2021, 8:53 PMturansky
08/23/2021, 8:56 PM@Serializable
enum class EnumValue {
@SerialId("OK") OK,
@SerialId("FAIL") FAIL,
;
}
vonox7
08/24/2021, 9:02 AMvonox7
08/24/2021, 9:04 AM@SerialName("OK") OK,
it fails with the same exceptionvonox7
08/24/2021, 9:06 AMedrd
08/24/2021, 10:54 PM