Hi,
i need some help with JSON3. If I add Arrays into my custom structure, I get error on JSON3.read.
MWE:
Base.@kwdef mutable struct MyStruct3
name::String = ""
par1::Int = 10
par2::Int32 = 32
par3::Array{Int,2} = [0 0 0]
end
JSON3.StructTypes.StructType(::Type{MyStruct3}) = JSON3.StructTypes.Mutable()
ms=MyStruct3()
JSON3.write(ms)
write(tempdir() * "/p1.json",JSON3.write(ms))
js=read(tempdir() * "/p1.json")
JSON3.read(js,MyStruct3)
and error:
ERROR: MethodError: no method matching Array{Int64,2}(::Array{Int64,1})
Closest candidates are:
Array{Int64,2}(::AbstractArray{S,N}) where {T, N, S} at array.jl:562
Array{Int64,2}(::UndefInitializer, ::Int64, ::Int64) where T at boot.jl:408
Array{Int64,2}(::UndefInitializer, ::Int64...) where {T, N} at boot.jl:412
Stacktrace:
[1] construct(::Type{T} where T, ::Array{Int64,1}; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\znidar\.julia\packages\StructTypes\CpLmq\src\StructTypes.jl:301
[2] construct(::Type{T} where T, ::Array{Int64,1}) at C:\Users\znidar\.julia\packages\StructTypes\CpLmq\src\StructTypes.jl:301
[3] #readarray#29 at C:\Users\znidar\.julia\packages\JSON3\hC8pW\src\structs.jl:207 [inlined]
[4] readarray at C:\Users\znidar\.julia\packages\JSON3\hC8pW\src\structs.jl:187 [inlined]
[5] #read#27 at C:\Users\znidar\.julia\packages\JSON3\hC8pW\src\structs.jl:183 [inlined]
[6] read at C:\Users\znidar\.julia\packages\JSON3\hC8pW\src\structs.jl:183 [inlined]
[7] #read#26 at C:\Users\znidar\.julia\packages\JSON3\hC8pW\src\structs.jl:182 [inlined]
[8] read at C:\Users\znidar\.julia\packages\JSON3\hC8pW\src\structs.jl:182 [inlined]
[9] #_#36 at C:\Users\znidar\.julia\packages\JSON3\hC8pW\src\structs.jl:373 [inlined]
[10] MutableClosure at C:\Users\znidar\.julia\packages\JSON3\hC8pW\src\structs.jl:372 [inlined]
[11] applyfield! at C:\Users\znidar\.julia\packages\StructTypes\CpLmq\src\StructTypes.jl:666 [inlined]
[12] #read!#39 at C:\Users\znidar\.julia\packages\JSON3\hC8pW\src\structs.jl:438 [inlined]
[13] read! at C:\Users\znidar\.julia\packages\JSON3\hC8pW\src\structs.jl:389 [inlined]
[14] #read#37 at C:\Users\znidar\.julia\packages\JSON3\hC8pW\src\structs.jl:380 [inlined]
Any suggestion?