JuliaIO / JSON.jl

JSON parsing and printing
Other
311 stars 100 forks source link

Feature: Allow specification of full dictionary type #340

Open jakewilliami opened 2 years ago

jakewilliami commented 2 years ago

I understand that the dicttype keyword argument allows one to specify the general dictionary in which the JSON object is stored when it is read/parsed. However, I think a outtype argument could be specified so that not all JSON reads as Dict{T, Any}. For example:

julia> s = raw"""{"a", {"b", ["c", "d", "e"]}}""";

julia> JSON.parse(s, outtype=Dict{String, Dict{String, Vector{String}}})
Dict{String, Dict{String, Vector{String}}} with 1 entry:
  "a" => Dict("b"=>["c", "d", "e"])