-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
For dictionaries which use Symbols as keys, the convert function fails.
Here is a minimal example to reproduce the error message
Dict{Symbol,Int64}( LazyJSON.value("""{"a":10}""") )Output:
ERROR: ArgumentError: "a" is not a valid key for type Symbol
Stacktrace:
[1] setindex!(::Dict{Symbol,Int64}, ::LazyJSON.Number{String}, ::LazyJSON.String{String}) at ./dict.jl:374
[2] Dict{Symbol,Int64}(::LazyJSON.Object{Nothing,String}) at ./dict.jl:103
[3] top-level scope at none:0
I am no Julia expert. Should it remain like this or would it be possible to add Symbols as supported keys?
Anyway, my workaround is to define
import Base.setindex!
function setindex!(d::Dict{Symbol,T}, v::LT, k::LazyJSON.String{String}) where {T, LT}
setindex!(d,v,Symbol(k))
endsuch that every LazyJSON.String is first converted to a Symbol.
Metadata
Metadata
Assignees
Labels
No labels