Schema.NET
Schema.NET copied to clipboard
Fix for null string values
Fixes:
- https://github.com/RehanSaeed/Schema.NET/issues/389
Looks like our issue is this block of code in S.T.J: https://source.dot.net/#System.Text.Json/System/Text/Json/Serialization/Metadata/JsonPropertyInfoOfT.cs,353
There are a couple of flags around there that we might be able to toggle to get this to behave correctly.
I should mention - that the block of code I linked to is likely based on the master/main code in the Runtime, not necessarily what we are using. ~We don't have individual control of HandleNullOnRead currently, just a HandleNull property which does read and write.~ (Edit: HandleNullOnRead is internal)
I imagine (though haven't confirmed) is that if we enable HandleNull, it might mean that null/default values are going to be serialized again.
Setting HandleNull does make our converter run however another internal part of S.T.J trips:

I'm thinking that S.T.J is doing this because a struct can't technically be null instead of setting the struct to its default value.
Tried to mess around with a few settings but doesn't seem like there is anything we can do without trying something drastic like switching Values and OneOrMany to be reference types.