Thoth.Json.Net
Thoth.Json.Net copied to clipboard
Bug: Unexpected sign for large int64 decoding.
open Thoth.Json.Net
type test_type = { i: int64 }
let extra = Extra.empty |> Extra.withInt64
let test_type_decoder = Decode.Auto.generateDecoder<test_type> (extra = extra)
let test_type_json1 = """{"i": 9223372036854775806}"""
let test_type_json2 = """{"i": 8223372036854775806}"""
let test_type1 = Decode.Auto.fromString<test_type> (test_type_json1, extra = extra)
let test_type2 = Decode.fromString test_type_decoder test_type_json2
printfn "test_type1: %A" test_type1
printfn "test_type2: %A" test_type2
For some reason the first value gets parsed as -ve. This seems to only happen for numbers close to the max value. Maybe some sort of overflow is happening.
I found this bug by making sure that Decode.Auto.fromString works the same way as Decode.Auto.generateDecoder, if you are wondering why I use 2 different techniques here.
Thank you for the report, I will investigate this issue while working on porting the Auto API to the new API.