https://kotlinlang.org logo
#serialization
Title
# serialization
e

Erik

11/03/2023, 4:17 PM
Is it possible to make conversion from
camelCase
(default Kotlin format) names to
snake_case
(my default serialized format) the default/automatic using kotlinx.serialization? E.g. I have
Copy code
@Serializable
data class Foo(
    val bar: Bar
    @SerialName("baz_qux")
    val bazQux: BazQux
)
I'd like that serial name to be the default / automatic, so that it's unnecessary / implied. I have many data classes with many properties, so it isn't very readable and easy to forget when using
@SerialName
for some of the properties (the ones that have multiple words in the name).
1
a

asdf asdf

11/03/2023, 4:27 PM
JsonNamingStrategy.SnakeCase seems like what you want
gratitude thank you 1
e

Erik

11/03/2023, 4:32 PM
Wow, so it seems. I did search in the docs, but hadn't found it