Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON3.read(json; jsonlines=true) can't handle trailing newlines #263

Open
mcmcgrath13 opened this issue Jun 21, 2023 · 0 comments
Open

JSON3.read(json; jsonlines=true) can't handle trailing newlines #263

mcmcgrath13 opened this issue Jun 21, 2023 · 0 comments

Comments

@mcmcgrath13
Copy link
Collaborator

The below snippet fails due to the double trailing newlines:

JSON3.read("1\n\n2\n\n";jsonlines=true)

Exception:

ERROR: ArgumentError: invalid JSON at byte position 7 while parsing type JSON3.Array: error
1

2



Stacktrace:
 [1] invalid(error::Function, buf::Base.CodeUnits{UInt8, String}, pos::Int64, T::Type)
   @ JSON3 ~/src/raicodes/.raicode-depots/mcm-mirror-outline-union-map/packages/JSON3/jTUC3/src/JSON3.jl:30
 [2] jsonlines!(buf::Base.CodeUnits{UInt8, String}, pos::Int64, len::Int64, b::UInt8, tape::Vector{UInt64}, tapeidx::Int64, checkint::Bool; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ JSON3 ~/src/raicodes/.raicode-depots/mcm-mirror-outline-union-map/packages/JSON3/jTUC3/src/read.jl:417
 [3] jsonlines!
   @ ~/src/raicodes/.raicode-depots/mcm-mirror-outline-union-map/packages/JSON3/jTUC3/src/read.jl:361 [inlined]
 [4] read(json::String; jsonlines::Bool, numbertype::Nothing, kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ JSON3 ~/src/raicodes/.raicode-depots/mcm-mirror-outline-union-map/packages/JSON3/jTUC3/src/read.jl:55
 [5] top-level scope
   @ REPL[5]:1

One trailing newline seems to be fine

JSON3.read("1\n\n2\n";jsonlines=true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant