Tarmil / FSharp.SystemTextJson

System.Text.Json extensions for F# types
MIT License
329 stars 45 forks source link

How to get the behaviour before breaking change #123 ? #138

Closed SamuelBerger closed 1 year ago

SamuelBerger commented 1 year ago

While updating to release version, our CI hits the breaking change #123 :(

Is there a way to configure the old behaviour:

IgnoreNullValues = true or DefaultIgnoreCondition = WhenWritingNull affects serializing as well.

Am I missing a trick (without changing all option properties to Skippable)?

(Throwing an exception for missing non option record properties is pure gold, so allowNullFields would never be an option.)

If there isn't a way to get the old behaviour, would a configuration optionFieldsSkippable be considered an improvement to the library?

ly29 commented 1 year ago

While I understand this change I think the previous default was the sane behavior and having expectations like built in is wrong.

So while I look into an replacement library, if any, it would be nice that the previous behaviour was at least an option.

Tarmil commented 1 year ago

Yes, I see that this is a common request. I agree that we should add an option to have the previous behavior without needing IgnoreNullValues/DefaultIgnoreCondition.

Tarmil commented 1 year ago

The new option SkippableOptionFields was added in v1.1 for this use case. https://github.com/Tarmil/FSharp.SystemTextJson/blob/master/docs/Customizing.md#skippable-option-fields

SamuelBerger commented 1 year ago

🤩Thank you @Tarmil ! You're the best!