Skip to content

Commit

Permalink
Fix UnionConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Jan 3, 2022
1 parent a107eb5 commit 2481fb6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ The `Unreleased` section name is replaced by the expected version of next releas
## [Unreleased]

### Added

- `SystemTextJson.UnionConverter`: Complete port of equivalent functionality in `NewtonsoftJson` equivalent [#59](https://github.com/jet/FsCodec/pull/59)

### Changed

- `SystemTextJson`: Target `System.Text.Json` v `6.0.1` [#59](https://github.com/jet/FsCodec/pull/59)
Expand Down
3 changes: 2 additions & 1 deletion src/FsCodec.SystemTextJson/UnionConverter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ type UnionConverter<'T>() =
for fieldInfo, fieldValue in Seq.zip fieldInfos fieldValues do
if fieldValue <> null || options.DefaultIgnoreCondition <> Serialization.JsonIgnoreCondition.Always then
writer.WritePropertyName(fieldInfo.Name)
JsonSerializer.Serialize(writer, fieldValue, options)
let element = JsonSerializer.SerializeToElement(fieldValue, fieldInfo.PropertyType, options)
element.WriteTo writer

writer.WriteEndObject()

Expand Down

0 comments on commit 2481fb6

Please sign in to comment.