Closed SamuelBerger closed 1 year ago
Hello! Can we get someone with write access to merge this? Looking forward to using it in our code...
Hi @Tarmil what is your opinion about the nested option problem?
I would rather keep the current behaviour by default, and implement this as opt-in.
An example use case I have for deserializing null
differently from the absence of the field is to parse HTTP PATCH
requests. This is a situation where the JSON being deserialized represents a modification of a stored object, such that:
"foo" = <something other than null>
will set the value of foo
;"foo" = null
will remove foo
from storage;"foo"
will leave the existing foo
as is.But I also understand your use case, so a new option on JsonFSharpOptions
is a welcome addition.
Yes, that makes sense. I will (hopefully this week) change the PR so it does not change the current behaviour and just fixes the bug.
The opt-in for flattening nested options would be a different change.
I also understand now the WithSkippableOptionFields configuration. It is a 1:1 replacement for https://github.com/Tarmil/FSharp.SystemTextJson/blob/master/docs/Format.md#skippable I initially understood it as "I won't be so harsh and throw an exception if you skip a field of type option instead of giving me a null" (as it was before 1.0 release)
@Tarmil one last thing to be on the safe side. Do you confirm #151 is a bug?
I assume it is not a bug then :) and close this tiny PR.
Fixes #151
I have changed 2 existing tests because
type Person = { FirstName: string; LastName: string voption option }
{ "FirstName": "Marie" }
and{ "FirstName": "Marie", "LastName": null }
should both result to
{ FirstName = "Marie"; LastName = None }
and notSome ValueNone
(outer most Option should be None)