quinnj / JSON3.jl

Other
214 stars 47 forks source link

`JSON3.read(str, MyStruct)` does not roundtrip correctly nor error #285

Open ericphanson opened 2 months ago

ericphanson commented 2 months ago
using StructTypes, JSON3

struct A
  a::Dict{Tuple{Int,Int}, Char}
end

StructTypes.StructType(::Type{A}) = StructTypes.Struct()

a = A(Dict((1, 2) => 'a', (2, 4) => 'b', (15, 20) => 'c'))

@show JSON3.read(JSON3.write(a), A)

results in

A(Dict((40, 50) => 'b', (40, 49) => 'c'))

IMO this should error instead.

From: https://discourse.julialang.org/t/json3-read-dict-tuple-int-int-t-unexpected-behavior/117759