Skip to content
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

Support for YAML transformations like there is for JSON #29

Open
Vampire opened this issue Aug 20, 2020 · 11 comments
Open

Support for YAML transformations like there is for JSON #29

Vampire opened this issue Aug 20, 2020 · 11 comments
Labels
enhancement New feature or request frozen help wanted Extra attention is needed

Comments

@Vampire
Copy link

Vampire commented Aug 20, 2020

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)

@charleskorn
Copy link
Owner

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.

@charleskorn charleskorn added enhancement New feature or request help wanted Extra attention is needed labels Aug 22, 2020
@Vampire
Copy link
Author

Vampire commented Aug 22, 2020

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. :-)

@stale
Copy link

stale bot commented Jul 7, 2022

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.

@stale stale bot added stale and removed stale labels Jul 7, 2022
@stale
Copy link

stale bot commented Sep 5, 2022

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.

@stale stale bot added stale and removed stale labels Sep 5, 2022
@stale
Copy link

stale bot commented Nov 4, 2022

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.

@stale stale bot added the stale label Nov 4, 2022
@stale
Copy link

stale bot commented Nov 11, 2022

This issue has been automatically closed because it has not had any recent activity.

@stale stale bot closed this as completed Nov 11, 2022
@Vampire
Copy link
Author

Vampire commented Nov 21, 2022

This is not implemented, is it? Please reopen.

@sschuberth
Copy link
Contributor

Maybe I find some time later

Are you still considering to contribute @Vampire?

@Vampire
Copy link
Author

Vampire commented Sep 5, 2024

@sschuberth I don't right now have the capacity to work on this, so if you want to do it, be my guest, would be highly appreciated. :-)

@sschuberth
Copy link
Contributor

I also have time restrictions, unfortunately. But I anyway wonder why KxS core has implemented JsonTransformingSerializer in a format-specific way. I would have expected such transformation to happen in some high-level class that works for all format / serializer implementations.

@sschuberth
Copy link
Contributor

Can we maybe just make the whole StringOrObjectSerializer.kt from Batect available as part of Kaml for now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frozen help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants