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

PolymorphismStyle.None #378

Closed
mgroth0 opened this issue Feb 5, 2023 · 6 comments
Closed

PolymorphismStyle.None #378

mgroth0 opened this issue Feb 5, 2023 · 6 comments
Labels

Comments

@mgroth0
Copy link

mgroth0 commented Feb 5, 2023

Describe the problem you'd like to solve

I would like to serialize classes belonging to a polymorphic hierarchy as if they were not. I understand this means they can no longer be correctly deserialized, so I understand why there might be hesitation to support such a feature. Maybe it can be part of a separate API.

Describe the solution you'd like

allowing PolymorphismStyle.None, which would simply do nothing when a class is polymorphic, would work for me. Alternatively, having a separate method to serialize objects without considering if they are polymorphic would be ok.

Describe alternatives you've considered

I am using PolymorphismStyle.Tag and trying to remove these tags by searching the string.

Additional context

I may be serializing an object which will be deserialized in another program altogether, and that other program does not need the polymorphic tags.

@charleskorn
Copy link
Owner

Thanks for the suggestion @mgroth0. If you're interested in submitting a PR with this change, I'd be happy to accept it.

@stale
Copy link

stale bot commented Apr 6, 2023

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 Apr 6, 2023
@stale
Copy link

stale bot commented Apr 13, 2023

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

@stale stale bot closed this as completed Apr 13, 2023
@mgroth0
Copy link
Author

mgroth0 commented Sep 15, 2023

@charleskorn I'm sorry I don't have time to submit a PR. Still though, can this be kept open? I think it is a valid suggestion.

@ZacSweers
Copy link
Contributor

I'll take a look at a PR

ZacSweers added a commit to ZacSweers/kaml that referenced this issue Dec 14, 2023
This implements charleskorn#378 by introducing a new `None` style that omits the tag/property entirely from the output yaml.

Note this is asymmetric and reads are treated the same as `Tag` as reads require a tag.

I added a few tests to JvmYamlWritingTest for both this case and some added coverage for the existing two cases as well.
@ZacSweers
Copy link
Contributor

#494

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants