Skip to content

System.Reflection.TargetInvocationException when serializing empty anonymous record #137

@peterhirn

Description

@peterhirn
#r "nuget: FSharp.SystemTextJson"

open System.Text.Json
open System.Text.Json.Serialization

let options = JsonSerializerOptions()
options.Converters.Add(JsonFSharpConverter())

JsonSerializer.Serialize({| x = {| |} |}, options)
System.Reflection.TargetInvocationException: Exception has been thrown by the target 
of an invocation.
 ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.    
   at System.Text.Json.Serialization.JsonRecordConverter`1..ctor(JsonSerializerOptions options, JsonFSharpOptions fsOptions) in /home/runner/work/FSharp.SystemTextJson/FSharp.SystemTextJson/src/FSharp.SystemTextJson/Record.fs:line 26

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions