-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
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"forOptionseems weird"$type": "Ok"forResultseems 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.UnwrapFieldlessTagsI 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.
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed