-
Notifications
You must be signed in to change notification settings - Fork 50
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
Encoding and Decoding case insensitive enums #587
Conversation
I need this as well. We switched from json files to yaml but are missing case-insensitive enum deserialization that the kotlinx serialization library has. Would love to see this merged soon if possible! |
override fun encodeEnum(enumDescriptor: SerialDescriptor, index: Int) { | ||
val element = enumDescriptor.getElementName(index) | ||
|
||
emitQuotedScalar(element, configuration.singleLineStringStyle.scalarStyle) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: I think if we don't change the encoding we should revert the code to the original state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its the same code, rather descriptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
@@ -52,6 +54,8 @@ public data class YamlConfiguration( | |||
internal val allowAnchorsAndAliases: Boolean = false, | |||
internal val yamlNamingStrategy: YamlNamingStrategy? = null, | |||
internal val codePointLimit: Int? = null, | |||
@ExperimentalSerializationApi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's a need to mark this as experimental.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the new api features are marked as experimental in the kotlinx.serialization
library when they are introduced. As a matter of fact, its their convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for the PR!
🎉 This PR is included in version 0.62.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Implemented case-insensitive enumeration encoding and decoding.
Changelogs
decodeEnumCaseInsensitive
defaults tofalse
.true
for consistency withJson
format.