Skip to content

Commit

Permalink
Merge pull request #128 from oxinabox/ox/cmd
Browse files Browse the repository at this point in the history
Support read(::AbstractCommand)
  • Loading branch information
quinnj authored Mar 5, 2021
2 parents 4ff5d84 + 8c85109 commit 56d5211
Show file tree
Hide file tree
Showing 2 changed files with 5 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
4 changes: 4 additions & 0 deletions test/json.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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[]]') == "[]"

Expand Down

0 comments on commit 56d5211

Please sign in to comment.