You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi
it looks there is an corner case not supported with unmarshal.
It happens where an empty Matrix is unmarshaled. A JSON matrix value [] is parsed to Any[]. Next, the unmarshaling of the form Unmarshal.unmarshal(Matrix{Int32}, Any[]) returns Any[]. Note that: typeof(Any[]) returns Vector{Any}. However, constructor for Matrix expects the type Matrix{Any}
MWE demonstrates this:
struct test
id::Int32
cs::Array{Int32,2}
end
julia> d1=test(3, reshape([],0,0))
test(3, Matrix{Int32}(undef, 0, 0))
julia> d2=JSON.json(d1)
"{\"id\":3,\"cs\":[]}"
julia> d3=JSON.parse(d2)
Dict{String, Any} with 2 entries:
"cs" => Any[]
"id" => 3
julia> d4=Unmarshal.unmarshal(test,d3,true)
test AbstractDict
\--> id <: Int32
\--> cs <: Matrix{Int32}
Array{Int32, 2}
ERROR: MethodError: no method matching Matrix{Int32}(::Vector{Any})
Closest candidates are:
Array{T, N}(::AbstractArray{S, N}) where {T, N, S} at C:\Programs\Julia-1.7.0\share\julia\base\array.jl:563
Matrix{T}(::LinearAlgebra.UpperTriangular) where T at C:\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\LinearAlgebra\src\triangular.jl:177
Matrix{T}(::LinearAlgebra.UpperHessenberg) where T at C:\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\LinearAlgebra\src\hessenberg.jl:68
...
I'd be glad if this could be fixed.
Simon
The text was updated successfully, but these errors were encountered:
Hi
it looks there is an corner case not supported with unmarshal.
It happens where an empty Matrix is unmarshaled. A JSON matrix value
[]
is parsed toAny[]
. Next, the unmarshaling of the formUnmarshal.unmarshal(Matrix{Int32}, Any[])
returnsAny[]
. Note that:typeof(Any[])
returnsVector{Any}
. However, constructor for Matrix expects the typeMatrix{Any}
MWE demonstrates this:
I'd be glad if this could be fixed.
Simon
The text was updated successfully, but these errors were encountered: