Open runenielsen opened 1 year ago
would be a breaking change and if done can't be done until Micronaut 5
FWIW all configuration possibilities are described at https://micronaut-projects.github.io/micronaut-serialization/latest/guide/configurationreference.html
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 🙂
Feature description
The default for micronaut.serde.serialization.inclusion is
non_empty
. It should be changed tonon_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
toapplication.properties
.Thanks for a great framework! 🙂