Set explicitNulls = false for kotlinx serialization#2897
Conversation
This is more inline with Jackson's behavior otherwise for nullable types with non default values, and they don't exist, gives a Missingfield exception whereas it worked on Jackson. We may need coerceInputValues = true also but I am unsure of that right now.
|
Actually this also prevents the encoding of explicit null values as well so it is a little different but it is the closest I could fine. I am actually unsure of this... |
|
|
|
@fire-light42 any thoughts here? (to note I was testing with a fully migrated everything and removed Jackson fallback to uncover a few issues with our current Json setup) |
|
We do aim to simulate exact Jackson behavior however possible, if this helps with that I see no issues. However, I would see these edge cases before I can make a proper decision. |
|
For example in RepositoryManager SitePlugin no plugins can load on kotlinx serialization if things like description is not passed. I got Missingfield exception on description in that case. |
|
In that case we absolutely need |
|
I dislike that encoding also strips the null. It should always encode null values, but allow missing null values too. |
|
As far as I can tell, it can't do both. As for coerceInputValues from my understanding, that turns invalid values to default values in some cases like nulls on non nullable types or an invalid enum. |
|
Unfortunate, but the explicitNulls behavior will still work with Jackson because missing fields become null. It just prevents us from turning it on in the future. |
|
Okay this should not be done. It corrupts all data. I just did some more tests and restoring from previous backups causes a lot of data to be corrupted or just plain missing |
|
Nevermind, that was my fault. Ironically the cause that broke it was that this fixed it in way more places then I thought, it was catching back to Jackson but this made it actually work to use kotlinx serialization but I had it wrong in my full migration, after fixing that if fully works. So this is still needed. |
This is more inline with Jackson's behavior otherwise for nullable types with non default values, and they don't exist, gives a Missingfield exception whereas it worked on Jackson. We may need coerceInputValues = true also but I am unsure of that right now.