From c6fac42d4a2b5d177407297cc198f612fa237d7e Mon Sep 17 00:00:00 2001 From: anand jain Date: Thu, 6 Oct 2022 14:28:17 -0400 Subject: [PATCH] jsontable(x::AbstractVector{<:JSON3.Object}) --- src/JSONTables.jl | 4 ++-- test/runtests.jl | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/JSONTables.jl b/src/JSONTables.jl index aeee99a..9038e37 100644 --- a/src/JSONTables.jl +++ b/src/JSONTables.jl @@ -31,11 +31,11 @@ function jsontable(x::JSON3.Object) return Table{true, typeof(x)}(names, types, x) end -jsontable(x::JSON3.Array) = throw(ArgumentError("input `JSON3.Array` must only have `JSON3.Object` elements to be considered a table")) +# jsontable(x::JSON3.Array) = throw(ArgumentError("input `JSON3.Array` must only have `JSON3.Object` elements to be considered a table")) missT(::Type{Nothing}) = Missing missT(::Type{T}) where {T} = T -function jsontable(x::JSON3.Array{JSON3.Object}) +function jsontable(x::AbstractVector{<:JSON3.Object}) names = Symbol[] seen = Set{Symbol}() types = Dict{Symbol, Type}() diff --git a/test/runtests.jl b/test/runtests.jl index 7d4b675..f1f79b1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -92,4 +92,10 @@ jt = JSONTables.jsontable(new_field_in_last_row) ct = Tables.columntable(jt) @test isequal(ct.c, [missing, 8]) +# jsontable(::Vector{JSON3.Object}) test +jstrs = JSON3.write.([Dict("a"=>rand(), "b"=>-rand()) for _ in 1:50]) +js = JSON3.read.(jstrs) +jt = jsontable(js) +@test jt isa JSONTables.Table + end