Consider this:
let data = {| Data = "This is a test"; Sub = {| Foo = Ok 1; Bar = [Some 2] |} |}
Log.Information("Data: {@Data}", data)
I get this:
{"Data": "This is a test", "Sub": {"Bar": [{"Value": 2, "$type": "Some"}], "Foo": {"ResultValue": 1, "$type": "Ok"}, "$type": "<>f__AnonymousType2950936943`2"}, "$type": "<>f__AnonymousType2576086083`2"}
There are several issues:
"$type": "Some" for Option seems weird
"$type": "Ok" for Result seems weird
"$type": "<>f__AnonymousType..." should not be there
Ideally, IMHO, for unions, you'd use a format like https://github.com/Tarmil/FSharp.SystemTextJson with union encoding set to
JsonUnionEncoding.Default
||| JsonUnionEncoding.InternalTag
||| JsonUnionEncoding.NamedFields
// And perhaps also this
||| JsonUnionEncoding.UnwrapFieldlessTags
I would therefore want something like this:
{"Data": "This is a test", "Sub": {"Bar": [2], "Foo": {"Case": "Ok", "ResultValue": 1}}}
I understand that this package is old and not actively maintained. I may end up writing my own library to destructure F# types.
Consider this:
I get this:
There are several issues:
"$type": "Some"forOptionseems weird"$type": "Ok"forResultseems weird"$type": "<>f__AnonymousType..."should not be thereIdeally, IMHO, for unions, you'd use a format like https://github.com/Tarmil/FSharp.SystemTextJson with union encoding set to
I would therefore want something like this:
I understand that this package is old and not actively maintained. I may end up writing my own library to destructure F# types.