kaml
kaml copied to clipboard
Support for YAML transformations like there is for JSON
I've just read https://github.com/Kotlin/kotlinx.serialization/blob/v0.20.0/docs/json_transformations.md and really like that. But I need that for YAML. If you want to deserialize a GitHub action definition file, you have for example exactly the use-case of polymorphism by shape. Would be really cool if kaml would also have such functionality built-in.
(Don't wonder that I'm reading the 0.20.0 docs, I'm using this in a Gradle build and therefore I cannot use 1.4.0 yet)
Hey @Vampire, this functionality isn't built in to kaml. If you'd be interested in adding it with a PR, I'd be happy to talk about possible solutions.
In the meantime, you can do something similar by implementing a custom serializer that casts the decoder to a YamlInput
and inspects the node
property. https://github.com/batect/batect/blob/master/app/src/main/kotlin/batect/config/io/deserializers/StringOrObjectSerializer.kt#L50 is an example of this technique - it looks at the node type to determine whether it is a string or an object.
I'm sorry, I'm right now too occupied with other contributions and actually I know the files I want to deserialize / serialize, so for now I just can live without the shape-based polymorphism. Maybe I find some time later or maybe you find time yourself in the meantime. :-)
This issue has been automatically marked as stale because it has not had any activity in the last 60 days. It will automatically be closed if no further activity occurs in the next seven days to enable maintainers to focus on the most important issues. If this issue is still affecting you, please comment below within the next seven days. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had any activity in the last 60 days. It will automatically be closed if no further activity occurs in the next seven days to enable maintainers to focus on the most important issues. If this issue is still affecting you, please comment below within the next seven days. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had any activity in the last 60 days. It will automatically be closed if no further activity occurs in the next seven days to enable maintainers to focus on the most important issues. If this issue is still affecting you, please comment below within the next seven days. Thank you for your contributions.
This issue has been automatically closed because it has not had any recent activity.
This is not implemented, is it? Please reopen.