Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wondering if json obj could convert to NamedTuple ? #10

Open
mlyz opened this issue Apr 6, 2019 · 0 comments
Open

wondering if json obj could convert to NamedTuple ? #10

mlyz opened this issue Apr 6, 2019 · 0 comments

Comments

@mlyz
Copy link

mlyz commented Apr 6, 2019

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant