diff --git a/src/read.jl b/src/read.jl index 3da5254..d6f8ad0 100644 --- a/src/read.jl +++ b/src/read.jl @@ -6,7 +6,7 @@ end Base.codeunits(x::VectorString) = x.bytes # high-level user API functions -read(io::IO; kw...) = read(Base.read(io, String); kw...) +read(io::Union{IO, Base.AbstractCmd}; kw...) = read(Base.read(io, String); kw...) read(bytes::AbstractVector{UInt8}; kw...) = read(VectorString(bytes); kw...) function read(str::AbstractString; jsonlines::Bool=false, kw...) diff --git a/test/json.jl b/test/json.jl index 7fe3617..1495526 100644 --- a/test/json.jl +++ b/test/json.jl @@ -729,6 +729,10 @@ let iob = IOBuffer() @test (JSON3.read(String(take!(iob)))).i == 1 end +# issue #127 support AbstractCmd +@test (JSON3.read(`echo \{\"i\":1\}`)).i == 1 +@test (JSON3.read(`echo` & `echo \{\"i\":1\}`)).i == 1 + @test_broken JSON3.write([Int64[] Int64[]]) == "[[],[]]" #TODO @test JSON3.write([Int64[] Int64[]]') == "[]"