Skip to content

Error with tuple as a dictionary key #399

@odow

Description

@odow

See JuliaCI/BenchmarkTools.jl#400 (comment)

(json) pkg> st
Status `/private/tmp/json/Project.toml`
  [682c06a0] JSON v1.1.0

julia> import JSON

julia> JSON.json(Dict(("a", "b") => 1))
ERROR: ArgumentError: No key representation for Tuple{String, String}. Define StructUtils.lowerkey(::Tuple{String, String})
Stacktrace:
 [1] lowerkey(::JSON.JSONWriteStyle, x::Tuple{String, String})
   @ JSON ~/.julia/packages/JSON/jLnej/src/write.jl:212
 [2] applyeach
   @ ~/.julia/packages/StructUtils/CvpPP/src/StructUtils.jl:563 [inlined]
 [3] json!(buf::Vector{…}, pos::Int64, x::Dict{…}, opts::JSON.WriteOptions{…}, ancestor_stack::Vector{…}, io::Nothing, ind::Int64, depth::Int64, bufsize::Int64)
   @ JSON ~/.julia/packages/JSON/jLnej/src/write.jl:617
 [4] json! (repeats 3 times)
   @ ~/.julia/packages/JSON/jLnej/src/write.jl:562 [inlined]
 [5] json(x::Dict{Tuple{String, String}, Int64}; pretty::Bool, kw::@Kwargs{})
   @ JSON ~/.julia/packages/JSON/jLnej/src/write.jl:433
 [6] json(x::Dict{Tuple{String, String}, Int64})
   @ JSON ~/.julia/packages/JSON/jLnej/src/write.jl:426
 [7] top-level scope
   @ REPL[5]:1
Some type information was truncated. Use `show(err)` to see complete types.

where previously

julia> import JSON

julia> JSON.json(Dict(("a", "b") => 1))
"{\"(\\\"a\\\", \\\"b\\\")\":1}"

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