Skip to content

Commit

Permalink
better parsing for typed dicts
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed May 28, 2024
1 parent 67803bc commit c6bfb15
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/stipple/parsers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ end
function stipple_parse(::Type{Symbol}, s::String)
Symbol(s)
end

# untyped Dicts to typed Dict's
function stipple_parse(::Type{<:AbstractDict{K, V}}, value::AbstractDict{String, <:Any}) where {K, V}
Dict( zip(Vector{K}(stipple_parse(Vector{K}, collect(keys(value)))), stipple_parse(Vector{V}, collect(values(value)))) )
function stipple_parse(D::Type{<:AbstractDict{K, V}}, value::AbstractDict) where {K, V}
if D isa LittleDict
D( stipple_parse(Vector{K}, collect(keys(value))), stipple_parse(Vector{V}, collect(values(value))) )
else
D( zip(Vector{K}(stipple_parse(Vector{K}, collect(keys(value)))), stipple_parse(Vector{V}, collect(values(value)))) )
end
end

# String to Integer
Expand Down

0 comments on commit c6bfb15

Please sign in to comment.