Hi, is there a way to have @SerialName inherited? ...
# serialization
j
Hi, is there a way to have @SerialName inherited? I have a sealed interface (I've tried sealed class too) like below, and would rather avoid duplicating
has_available_stock
in each data class. My only option so far is to have a const val but that seems less ideal.
Copy code
@Serializable
internal sealed interface Foo {
    @SerialName("has_available_stock")
    val hasAvailableStock: Boolean

    @Serializable
    data class Foo1(
        override val hasAvailableStock: Boolean
    ) : Foo

    @Serializable
    data class Foo2(
        override val hasAvailableStock: Boolean
    ) : Foo
}
e
in this particular case,
Copy code
Json { namingStrategy = JsonNamingStrategy.Builtins.SnakeCase }