JSON v1.5.1 internally enforces the use of JSONReadStyle, which doesn't forward the StructUtils API to the corresponding methods defined for custom JSONStyle, breaking previous deserialization behaviour from JSON 1.5.0.
Minimal reproducing example
import JSON, StructUtils
@kwdef struct A
vals::Dict{String, Int} = Dict{String, Int}()
end
Base.keytype(::A) = String
Base.valtype(::A) = Int
StructUtils.addkeyval!(a::A, k, v) = StructUtils.addkeyval!(a.vals, k, v)
struct CustomJSONStyle <: JSON.JSONStyle end
StructUtils.dictlike(::CustomJSONStyle, ::Type{A}) = true
str = """{"a": 1, "b": 2 }"""
On JSON 1.5.0
julia> JSON.parse(str, A; style=CustomJSONStyle())
A(Dict("b" => 2, "a" => 1))
On JSON 1.5.1
julia> JSON.parse(str, A; style=CustomJSONStyle())
ERROR: TypeError: in typeassert, expected Dict{String, Int64}, got a value of type Nothing
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/StructUtils/RFX5w/src/StructUtils.jl:-1 [inlined]
[2] _construct
@ ~/.julia/packages/StructUtils/RFX5w/src/StructUtils.jl:1154 [inlined]
[3] makestruct
@ ~/.julia/packages/StructUtils/RFX5w/src/StructUtils.jl:1176 [inlined]
[4] make
@ ~/.julia/packages/StructUtils/RFX5w/src/StructUtils.jl:942 [inlined]
[5] _parse
@ ~/.julia/packages/JSON/5986W/src/parse.jl:223 [inlined]
[6] parse(x::JSON.LazyValue{…}, ::Type{…}; dicttype::Type{…}, null::Nothing, style::CustomJSONStyle, unknown_fields::Symbol)
@ JSON ~/.julia/packages/JSON/5986W/src/parse.jl:217
[7] parse
@ ~/.julia/packages/JSON/5986W/src/parse.jl:217 [inlined]
[8] #parse#52
@ ~/.julia/packages/JSON/5986W/src/parse.jl:207 [inlined]
[9] top-level scope
@ REPL[12]:1
Some type information was truncated. Use `show(err)` to see complete types.
JSON v1.5.1 internally enforces the use of
JSONReadStyle, which doesn't forward theStructUtilsAPI to the corresponding methods defined for customJSONStyle, breaking previous deserialization behaviour from JSON 1.5.0.Minimal reproducing example
On JSON
1.5.0On JSON
1.5.1