Hi folks, we are using KTX Serialization and I hav...
# kotlin-native
s
Hi folks, we are using KTX Serialization and I have notice a weird behavior. We use the type JsonObject in couple types that are exported to iOS and we have couple extensions functions that for JsonObject. Apparently, the Kotlin Native compiler for Darwin is just losing the JsonObject type and converting it to
NSDictionary
. Our working code on Android is crashing on iOS because of that. Anyone face that issue and know if there is any workaround to force to keep the JsonObject type?
Copy code
public fun JsonObject.asPrimitiveMap(): Map<String, Any?> =
    entries.associate {
        it.key to it.value.extractedContent
    }
Copy code
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("SerializationExKt")))
@interface KotlinSharedSerializationExKt : KotlinSharedBase
+ (NSDictionary<NSString *, id> *)asPrimitiveMap:(NSDictionary<NSString *, KotlinSharedKotlinx_serialization_jsonJsonElement *> *)receiver __attribute__((swift_name("asPrimitiveMap(_:)")));
@end
Is crashing on iOS when trying to call
entries
a
Yes, I had experience this, I had to implement a util extension in the common module to be the middle man between what it generates the JsonObject with the next task to process this
why do you need a primitiveMap here?