-
Notifications
You must be signed in to change notification settings - Fork 618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a default serializer for kotlin.uuid.Uuid class #2730
Comments
How do you want to serialize it for different formats? In string formats, like JSON, properties, xml etc., it is common to use the string representation, but for binary formats, a compact binary (using the two longs directly) would be preferred than encoding the string. |
Good question. Initially, I was planning to add only String representation, but maybe binary serializer is also required as an additional one |
Apparently, there is no standardized way of storing UUIDs in protobuf (protocolbuffers/protobuf#2224, https://groups.google.com/g/protobuf/c/THxuTQKsz54). Various implementations use For CBOR, there is tag 37 for UUID byte string (https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml), which is an accepted extension described here: https://github.com/lucas-clemente/cbor-specs/blob/master/uuid.md So it looks like, for now, only CBOR requires additional handling. |
On the avro binary format, the uuid is officially represented as a string as said by the spec (the default official uuid type), but is also usually serialized as a fixed of 16 bytes to save space (36 characters/bytes vs 16 bytes), so we may also want to handle a uuid differently depending on the user config. EDIT: |
Well, in the case of format-specific serializers, you can always mark |
in a simple .toString()/.parse() form. It is expected to be added as a standard serializer to the Kotlin 2.1 serialization plugin. Fixes #2730
…plugin UuidSerializer should appear in 1.7.1. Related ticket: Kotlin/kotlinx.serialization#2730
…plugin UuidSerializer should appear in 1.7.1. Related ticket: Kotlin/kotlinx.serialization#2730
in a simple .toString()/.parse() form. It is expected to be added as a standard serializer to the Kotlin 2.1 serialization plugin. Fixes #2730
…plugin UuidSerializer should appear in 1.7.1. Related ticket: Kotlin/kotlinx.serialization#2730
…plugin UuidSerializer should appear in 1.7.1. Related ticket: Kotlin/kotlinx.serialization#2730
in a simple .toString()/.parse() form. It is expected to be added as a standard serializer to the Kotlin 2.1 serialization plugin. Fixes #2730
Kotlin 2.0.20 is expected to have a new MPP UUID class (https://youtrack.jetbrains.com/issue/KT-31880, JetBrains/kotlin@25ea5e8). It is reasonable to provide a built-in serializer for it, like we did for
kotlin.time.Duration
when it was moved to stdlib.Adding a built-in serializer requires changes in the plugin too, so they have to be made in time, preferably in the same Kotlin 2.0.20 or Kotlin 2.1
The text was updated successfully, but these errors were encountered: