diff --git a/Project.toml b/Project.toml index 39e3176..5e8b158 100644 --- a/Project.toml +++ b/Project.toml @@ -18,7 +18,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] julia = "0.7, 1.0" -Parsers = "0.1, 0.2, 0.3, 1" +Parsers = "1, 2" [targets] test = ["DataStructures", "Distributed", "FixedPointNumbers", "OffsetArrays", "Sockets", "Test"] diff --git a/src/Parser.jl b/src/Parser.jl index 5b1f9d7..cbebf23 100644 --- a/src/Parser.jl +++ b/src/Parser.jl @@ -319,17 +319,7 @@ byte before `to`. Bytes enclosed should all be ASCII characters. float_from_bytes(bytes::MemoryParserState, from::Int, to::Int) = float_from_bytes(bytes.utf8, from, to) function float_from_bytes(bytes::Union{String, Vector{UInt8}}, from::Int, to::Int)::Union{Float64,Nothing} - # Would like to use tryparse, but we want it to consume the full input, - # and the version in Parsers does not do this. - - # return Parsers.tryparse(Float64, @view bytes.utf8[from:to]) - - len = to - from + 1 - x, code, vpos, vlen, tlen = Parsers.xparse(Float64, bytes, from, to, Parsers.OPTIONS) - if !Parsers.ok(code) || vlen < len - return nothing - end - return x::Float64 + return Parsers.tryparse(Float64, bytes isa String ? SubString(bytes, from:to) : view(bytes, from:to)) end """ diff --git a/test/json-checker.jl b/test/json-checker.jl index 7d0594b..6552108 100644 --- a/test/json-checker.jl +++ b/test/json-checker.jl @@ -1,6 +1,6 @@ # Run modified JSON checker tests -const JSON_DATA_DIR = joinpath(dirname(@__DIR__), "data") +const JSON_DATA_DIR = joinpath(dirname(pathof(JSON)), "../data") for i in 1:38 file = "fail$(lpad(string(i), 2, "0")).json"