You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to pass a JsonObject to Swift i get the following error Could not cast value of type "KListAsNSArray" to "Kotlinx_serialization_jsonJsonElement"
It seem that the interface List on JsonArray is taking over JsonElement in that situation.
To Reproduce
// Crash (also if it's an interface like MyListener { fun onAnswer(inData: JsonObject) }funtest(listener: (JsonObject) ->Unit) {
listener(
buildJsonObject {
put("test", "test")
putJsonArray("test2") {
add("test")
add("test2")
}
}
)
}
As a workaround, you can write all JsonElement-related functions in Kotlin and use Swift only to call these functions. It is far from ideal, but this is how Kotlin/Swift interop is currently designed.
So if you have function like test3() in your example that only returns JsonObject or even a Map/String you should be fine
Describe the bug
When I try to pass a JsonObject to Swift i get the following error
Could not cast value of type "KListAsNSArray" to "Kotlinx_serialization_jsonJsonElement"
It seem that the interface List on JsonArray is taking over JsonElement in that situation.
To Reproduce
If it's directly a JsonArray it work
If it's in a returned value it also work
Expected behavior
It should detect it as a jsonElement not a list and so work in this case
Environment
The text was updated successfully, but these errors were encountered: