Skip to content

Serializing member properties on record types #92

@jchannon

Description

@jchannon

With something like this:

type Pitstop =
    { 
          ATime: DateTimeOffset
          BTime:DateTimeOffset
        }
    member this.Name = "Dave"
    member this.Result = (this.BTime - this.ATime).TotalSeconds

And execute the serializer:

    let options = JsonSerializerOptions()
    options.Converters.Add(JsonFSharpConverter())
    options.PropertyNameCaseInsensitive <- true
    printfn "%s" (JsonSerializer.Serialize({ATime=DateTimeOffset.UtcNow
                                            BTime = DateTimeOffset.UtcNow.AddMinutes(1.0)}, options))

The output does not contain the member properties. Remove the converter in the options and it does get printed out.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions