Skip to content

wondering if json obj could convert to NamedTuple ? #10

@mlyz

Description

@mlyz

wondering why the following doesn't work. Any advice would be greatly appreciated.

julia> testj =
       """{
       "x": 1,
       "y": "a"
       }""";

julia> testl = LazyJSON.value(testj);

julia> convert(NamedTuple{(:x, :y), Tuple{Int, String}}, testl)
ERROR: MethodError: no method matching NamedTuple{(:x, :y),Tuple{Int64,String}}(::LazyJSON.Number{String}, ::LazyJSON.String{String})
Closest candidates are:
  NamedTuple{(:x, :y),Tuple{Int64,String}}(::Any) where {names, T<:Tuple} at namedtuple.jl:92
Stacktrace:
 [1] macro expansion at /home/yx/.julia/packages/LazyJSON/EmafJ/src/AbstractDict.jl:82 [inlined]
 [2] convert(::Type{NamedTuple{(:x, :y),Tuple{Int64,String}}}, ::LazyJSON.Object{Nothing,String}) at /home/yx/.julia/packages/LazyJSON/EmafJ/src/AbstractDict.jl:82
 [3] top-level scope at none:0

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