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

Ayfri

08/03/2022, 5:05 PM
Is there a way to create a
JSONTransformingSerializer
to replace all keys with a
snake_case
instead of a
camelCase
that works for any data class ?
d

Dominaezzz

08/03/2022, 5:49 PM
Yes
You just need to iterate over the keys to do the convertion.
a

Ayfri

08/03/2022, 6:53 PM
But how do I make it to work for any class ? So I don't have to create a serializer for every classes I have ?
d

Dominaezzz

08/03/2022, 6:55 PM
Ohhhhh. Yeah that's not possible yet. There's an open issue for it though.
a

Ayfri

08/03/2022, 7:06 PM
Ah :( So I'll stick with having 100
@SerialName
for my classes x)
8 Views