I am migrating my android app to multiplatform and I have an abstract class with four child classes.
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes(value = [
JsonSubTypes.Type(value = Image::class, name = "image"),
JsonSubTypes.Type(value = Video::class, name = "video"),
JsonSubTypes.Type(value = Audio::class, name = "audio"),
JsonSubTypes.Type(value = Text::class, name = "text")
])
abstract class Data: MyParcelable {
...
}
I added the following dependencies to commonMain:
implementation(libs.jackson.module.kotlin)
implementation(libs.jackson.datatype.jsr310)
implementation(libs.jackson.annotation)
Unfortunately, I cannot import com.fasterxml.* packages when iosX64 or iosArm64 is active as target.
I can't find any statement if fasterxml jackson is supported for multiplatform development for ios and desktop. Do you have information on using the annotations in kmp projects?
Jackson is written in Java, not Kotlin.
As such, it will support JVM and Android targets, but I do not expect it to be available for iOS or Web (Wasm or JS).
You might consider kotlinx serialization, along with this library for XML support.