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

Selective withTransientEmpty #1166

Open
beneyal opened this issue Jul 9, 2024 · 2 comments
Open

Selective withTransientEmpty #1166

beneyal opened this issue Jul 9, 2024 · 2 comments
Labels

Comments

@beneyal
Copy link

beneyal commented Jul 9, 2024

Hello,

Is there a way I can choose which case class fields I want to appear in the resulting JSON as empty containers and which ones I don't want to appear at all, preferably without changing my case class field definitions? Much of this library is still pretty magical to me, so I don't know if I'm missing something obvious 😅

Thank you for your time and for the amazing library!

@plokhotnyuk
Copy link
Owner

plokhotnyuk commented Jul 9, 2024

@beneyal Thanks for your feedback!

Unfortunately, it is not possible to do on the field level. It would be a good feature to add corresponding compile-time annotations for remaining derivation configuration options that are not supported on that level yet.

For now you can try a couple of workaround based on types:

  • define some separate type or a wrapper (as example that one which extends AnyVal) and create a custom codec with different configuration for it
  • wrap optional fields into Option type and use a separated configuration withTransientNone for them.

@beneyal
Copy link
Author

beneyal commented Jul 9, 2024

Thanks for the light-speed response! I will definitely try those options!

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

2 participants