Skip to content

Non-string Dict keys - regression from JSON3.jl #422

@carpetdev

Description

@carpetdev

Using JSON3.jl, I've been successfully roundtripping dictionaries with integer keys:

JSON3.read(JSON3.write(Dict(1=>1), Dict{Int,Int})
# Success

I'm aware that JSON object keys are strings so the produced JSON is actually "{\"1\":1}", but I've assumed the successful deserialization was by design.

Using JSON.jl, this errors:

JSON.parse(JSON.json(Dict(1=>1)), Dict{Int,Int})
# ERROR: MethodError: Cannot `convert` an object of type String to an object of type Int64

Is this to do with StructUtils.jl being less forgiving by default than StructTypes.jl?

In my specific use case I can actually replace my dictionary with a vector, but in general I might not have been able to.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions