Skip to content

Unexpected end of input error when parsing input streams #314

Open
@julbinb

Description

@julbinb

When parsing JSON values from an input stream like this

using JSON

while !eof(stdin)
  JSON.parse(stdin)
end

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 file 1.in contains just 5 (no spaces before or after the number), this works:

$ julia parse.jl < 1.in

But if 2.in contains [5] instead (no spaces before or after the list), then there is an error:

$ julia parse.jl < 2.in
ERROR: LoadError: Unexpected end of input
 ...when parsing byte with value '10'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions