From bc73d23525ce13d8f918a9ba97c315c044eff04a Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Sun, 27 Oct 2019 00:08:48 -0600 Subject: [PATCH] Fix tuple reading issue in a struct --- src/structs.jl | 3 ++- test/runtests.jl | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/structs.jl b/src/structs.jl index b45e188..83d108e 100644 --- a/src/structs.jl +++ b/src/structs.jl @@ -530,7 +530,7 @@ end @wh if N == i if b == UInt8(']') - return pos, Base.@ncall i tuple x + return pos + 1, Base.@ncall i tuple x else error = ExpectedClosingArrayChar @goto invalid @@ -842,6 +842,7 @@ end pos += 1 return pos, y elseif b != UInt8(',') + @show pos, y, Char(b) error = ExpectedComma @goto invalid end diff --git a/test/runtests.jl b/test/runtests.jl index f0fcd4a..18598db 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,9 @@ using Test, JSON3, UUIDs +struct data + t :: Tuple{Symbol, String} +end + @enum Fruit apple banana struct XInt @@ -636,4 +640,7 @@ obj = JSON3.read("{\"a\":\"b\", \"b\":null, \"c\":[null,null]}") @test JSON3.read("[\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\",\"hey\"]", NTuple{35, String}) == ("hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey", "hey") +JSON3.StructType(::Type{data}) = JSON3.Struct() +@test JSON3.read("{\"t\":[\"car\",\"Mercedes\"]}", data) == data((:car, "Mercedes")) + end # @testset "JSON3"