Skip to content

Commit e00474a

Browse files
authored
Merge pull request #78 from pchalamet/feature/trim-workaround
trim workaround (issue #77)
2 parents 999fbbc + 708c4e8 commit e00474a

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/FSharp.SystemTextJson/Collection.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type JsonListConverter<'T>(fsOptions) =
1212
let needsNullChecking = not tIsNullable && not tType.IsValueType
1313

1414
override _.Read(reader, _typeToConvert, options) =
15-
let array = JsonSerializer.Deserialize<'T[]>(&reader, options)
15+
let array = JsonSerializer.Deserialize(&reader, typeof<'T[]>, options) :?> 'T[]
1616
if needsNullChecking then
1717
for elem in array do
1818
if isNull (box elem) then

tests/FSharp.SystemTextJson.TrimTest/Program.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ open Xunit
66
let ``Regression #77`` () =
77
let options = JsonSerializerOptions()
88
options.Converters.Add(JsonFSharpConverter())
9-
Assert.Equal<int>([1; 2; 3], JsonSerializer.Deserialize<int list>("[1,2,3]", options))
9+
Assert.Equal<int list>([1; 2; 3], JsonSerializer.Deserialize("[1,2,3]", options))
10+
Assert.Equal("""[1,2,3]""", JsonSerializer.Serialize([1;2;3], options))
1011

1112
[<EntryPoint>]
1213
let main args = Xunit.ConsoleClient.Program.Main args

0 commit comments

Comments
 (0)