Skip to content

Commit

Permalink
Support read(::AbstractCommand)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox committed Mar 5, 2021
1 parent 4ff5d84 commit d4672e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
5 changes: 5 additions & 0 deletions test/json.jl
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,11 @@ 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[]]') == "[]"

Expand Down

0 comments on commit d4672e3

Please sign in to comment.