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

Change the default value for micronaut.serde.serialization.inclusion to non_null #560

Open
runenielsen opened this issue Sep 1, 2023 · 3 comments
Labels
status: under consideration The issue is being considered, but has not been accepted yet

Comments

@runenielsen
Copy link

runenielsen commented Sep 1, 2023

Feature description

The default for micronaut.serde.serialization.inclusion is non_empty. It should be changed to non_null.

Reason: It is not correct to just remove empty strings and empty arrays from the resulting JSON when serializing. This may work fine in most cases for JavaScript, but it means that serialize + deserialize on some objects in more strict language like Java and Kotlin will result in objects, that are not a copy of the original.

non_null is a much more sensible default, that avoids this problem.

See also the failing test case testMicronautSerializationAndDeserializationWithEmptyProperties in SerializeEmptyPropertiesTest in https://github.com/runenielsen/serialize-empty-properties for a demonstration of a case where serialization + deserialization does not result in a copy of the original object.

All the failing test cases are fixed, when you add micronaut.serde.serialization.inclusion=non_null to application.properties.

Thanks for a great framework! 🙂

@graemerocher
Copy link
Contributor

would be a breaking change and if done can't be done until Micronaut 5

@graemerocher graemerocher added the status: under consideration The issue is being considered, but has not been accepted yet label Sep 1, 2023
@graemerocher
Copy link
Contributor

FWIW all configuration possibilities are described at https://micronaut-projects.github.io/micronaut-serialization/latest/guide/configurationreference.html

@runenielsen
Copy link
Author

runenielsen commented Sep 1, 2023

Ah, thanks. I'm blind and didn't notice that link, because it is in the page header. Sorry about that.

I removed the part about the configuration documentation missing from the issue description 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: under consideration The issue is being considered, but has not been accepted yet
Projects
None yet
Development

No branches or pull requests

2 participants