Join Slack
Communities
Powered by
Is there a way to newtype something in Kotlin, suc...
# compiler
r
reactormonk
03/13/2024, 3:53 PM
Is there a way to newtype something in Kotlin, such that the serialization plugin treats it transparently, but it's tagged by the type system? Mostly for
String
stuff.
a
Adam S
03/13/2024, 3:58 PM
value classes are encoded/decoded as the underlying type
https://github.com/Kotlin/kotlinx.serialization/blob/v1.6.3/docs/value-classes.md#serialization-and-value-classes-ir-specific
or you can use a typealias
https://github.com/Kotlin/kotlinx.serialization/blob/v1.6.3/docs/serializers.md#specifying-serializer-globally-using-typealias
65
Views
Open in Slack
Previous
Next