Skip to content

Commit e63a1bb

Browse files
authored
Merge pull request #9 from JuliaData/jq/columnar
Fix #7 by adding an additional validation check on columnar json sources
2 parents a8b796a + 137a2e3 commit e63a1bb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/JSONTables.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ end
1212

1313
function jsontable(source)
1414
x = JSON3.read(source)
15-
columnar = x isa JSON3.Object
15+
columnar = x isa JSON3.Object && first(x)[2] isa AbstractArray
1616
columnar || x isa JSON3.Array || throw(ArgumentError("input json source is not a table"))
1717
return Table{columnar, typeof(x)}(x)
1818
end

test/runtests.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,15 @@ JSONTables.objecttable(io, ctable)
5454
JSONTables.arraytable(io, rtable)
5555
@test String(take!(io)) == rjson
5656

57+
# #7
58+
text = """{
59+
"color_scheme": "Packages/Color Scheme - Default/Mariana.sublime-color-scheme",
60+
"dictionary": "Packages/Language - English/en_US.dic",
61+
"draw_white_space": "all",
62+
"font_face": "monospace 821",
63+
"font_size": "10",
64+
"theme": "Adaptive.sublime-theme"
65+
}"""
66+
@test_throws ArgumentError JSONTables.jsontable(text)
67+
5768
end

0 commit comments

Comments
 (0)