Skip to content

Commit 63798a0

Browse files
committed
Allow objecttable and arraytable to take IO arguments
1 parent 77574a3 commit 63798a0

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/JSONTables.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ function Base.iterate(x::ArrayTable, st)
7575
end
7676

7777
objecttable(table) = JSON3.write(ObjectTable(Tables.columns(table)))
78+
objecttable(io::IO, table) = JSON3.write(io, ObjectTable(Tables.columns(table)))
7879
arraytable(table) = JSON3.write(ArrayTable(Tables.rows(table)))
80+
arraytable(io::IO, table) = JSON3.write(io, ArrayTable(Tables.rows(table)))
7981

8082
end # module

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,11 @@ rjtable = JSONTables.jsontable(rjson)
4747
@test JSONTables.arraytable(ctable) == rjson
4848
@test JSONTables.arraytable(rtable) == rjson
4949

50+
io = IOBuffer()
51+
JSONTables.objecttable(io, ctable)
52+
@test String(take!(io)) == cjson
53+
54+
JSONTables.arraytable(io, rtable)
55+
@test String(take!(io)) == rjson
56+
5057
end

0 commit comments

Comments
 (0)