Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializing member properties on record types #92

Closed
jchannon opened this issue Feb 22, 2021 · 3 comments
Closed

Serializing member properties on record types #92

jchannon opened this issue Feb 22, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@jchannon
Copy link

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.

@severisv
Copy link

Any workaround for this?

@Tarmil
Copy link
Owner

Tarmil commented Jun 17, 2022

Not currently, no. But you're the third person now asking for it; I'll look into adding it as an optional behavior.

@Tarmil Tarmil added the enhancement New feature or request label Jun 17, 2022
@Tarmil Tarmil self-assigned this Jun 30, 2022
@Tarmil
Copy link
Owner

Tarmil commented Nov 30, 2022

This was added in v1.0 with the option includeRecordProperties: bool.

@Tarmil Tarmil closed this as completed Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants