-
Notifications
You must be signed in to change notification settings - Fork 102
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
Unexpected end of input error when parsing input streams #314
Comments
A minimal working example is simply using JSON
JSON.parse("")
|
What makes you say it is valid JSON? Also, returning |
I was too hasty with commenting. An empty string is not valid JSON and the current behavior seems to be correct. My bad. |
I am having a similar issue. # This works fine
JSON.parse("123")
# This errors with "Unexpected end of input"
JSON.parse(IOBuffer("123")) |
Curiously, JSON.parse(IOBuffer("123\n")) works just fine. |
Maybe Line 108 in 1c24980
eof check.
|
Created #321 for this. |
Related to the above, I just wanted to comment that the current error message for the very simple reproducer is not helpful: julia> using JSON
julia> JSON.parse("")
ERROR: Unexpected end of input
Line: 0
Around: ......
^
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] _error(message::String, ps::JSON.Parser.MemoryParserState)
@ JSON.Parser ~/.julia/packages/JSON/QXB8U/src/Parser.jl:140
[3] byteat
@ ~/.julia/packages/JSON/QXB8U/src/Parser.jl:49 [inlined]
[4] parse_value(pc::JSON.Parser.ParserContext{Dict{String, Any}, Int64, true, nothing}, ps::JSON.Parser.MemoryParserState)
[5] parse(str::String; dicttype::Type, inttype::Type{Int64}, allownan::Bool, null::Nothing)
@ JSON.Parser ~/.julia/packages/JSON/QXB8U/src/Parser.jl:450
[6] parse(str::String)
@ JSON.Parser ~/.julia/packages/JSON/QXB8U/src/Parser.jl:448 We saw this error message in the wild, and it wasn't at all clear to me what it was indicating. My two requests for improvement:
|
When parsing JSON values from an input stream like this
depending on the type of a value in the input, parsing either succeeds or fails.
For example, if the code above is in
parse.jl
, and file1.in
contains just5
(no spaces before or after the number), this works:But if
2.in
contains[5]
instead (no spaces before or after the list), then there is an error:The text was updated successfully, but these errors were encountered: