Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/FSharp.SystemTextJson.Tests/Test.Record.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ module NonStruct =
let actual = JsonSerializer.Deserialize """{"ax":1,"ay":"b"}"""
Assert.Equal({ ax = 1; ay = "b" }, actual)

[<Fact>]
let ``deserialize empty record with ignore-null-values on`` () =
let options = JsonSerializerOptions(DefaultIgnoreCondition = Serialization.JsonIgnoreCondition.WhenWritingNull)
try
JsonSerializer.Deserialize<A>("{}", options) |> ignore
with
| :? System.NullReferenceException -> failwith "Unexpected NRE."
| ex when ex.Message.Contains("Missing field for record type") -> () // It's expected to fail since the record requires its fields to be initialized.

[<Fact>]
let ``serialize via explicit converter`` () =
let actual = JsonSerializer.Serialize { ax = 1; ay = "b" }
Expand Down