Thoth.Json
Thoth.Json copied to clipboard
feat: add support for `losslessOption`
Add ability to support lossless option.
With the current implementation of Thoth.json, None
or Some (Some None)
are both encoded has null
.
This PR introduce 2 new API:
-
lossyOption
: is equivalent to the oldoption
API/ None ull / Some None ull / Some 42 2 // Some (Some 42) 2
-
losslessOption
which is able to differentiate the nested options/ None "$type": "option", "$case": "none" / Some None "$type": "option", "$case": "some", "$value": { "$type": "option", "$case": "none" } / Some 42 "$type": "option", "$case": "some", "$value": 42 // Some (Some 42) { "$type": "option", "$case": "some", "$value": { "$type": "option", "$case": "some", "$value": 42 } }
[!WARNING] The old
Decode.option
andEncode.option
will be completely removed. People, will need to manual path their code to use thelossyOption
API.I am removing the API completely because the API changes only impact the new version of Thoth.Json, so this is I believe the perfect moment to do it instead of introducing an
Obsolete
warning to be removed later on.If you think differently please voice int
If we agree on the implementation, we will need to also change the object
builder API to reflect this changes too.