diff --git a/src/Parser.jl b/src/Parser.jl index 5b1f9d7..0a4eaf1 100644 --- a/src/Parser.jl +++ b/src/Parser.jl @@ -105,7 +105,7 @@ Return `true` if there is a current byte, and `false` if all bytes have been exausted. """ @inline hasmore(ps::MemoryParserState) = ps.s ≤ length(ps) -@inline hasmore(ps::StreamingParserState) = true # no more now ≠ no more ever +@inline hasmore(ps::StreamingParserState) = !ps.used || !eof(ps.io) """ Remove as many whitespace bytes as possible from the `ParserState` starting from diff --git a/test/runtests.jl b/test/runtests.jl index d585154..0d950d0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -42,6 +42,10 @@ include("json-samples.jl") @test JSON.parse("1") == 1 @test JSON.parse("1.5") == 1.5 @test JSON.parse("[true]") == [true] + + # test for parsing single values in streams + @test JSON.parse(IOBuffer("123")) == 123 + @test JSON.parse(IOBuffer("1.5")) == 1.5 end end