https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
d

dave08

02/10/2021, 7:58 PM
How are platform specific annotations handled in common code? Say, in js I need to use kotlin serialization, whereas on the server, Micronaut uses Jackson...?
b

Big Chungus

02/10/2021, 8:11 PM
Copy code
// commonMain
expect annotation class Serializable

// jvmMain
actual typealias Serializable = JsonObject // or whatever jackson alternative is

// jsMain
actual typealias Serializable = kotlinx.serialization.Serializable
d

dave08

02/11/2021, 10:08 AM
Yeah, but how would you handle the annotation's parameters? Like
@Json("realfieldname")
...?
b

Big Chungus

02/11/2021, 10:18 AM
Same way
typealias on one platform and delegate on the other