Skip to content

JSON::ResumableParser: error column does not match the input position #1022

@mame

Description

@mame

The column in a ResumableParser error is counted from the start of the current internal buffer, which moves as input is consumed (and shrunk), so it does not correspond to the input.

require "json"
parser = JSON::ResumableParser.new
parser << "[" + "1," * 500 + "999"   # > 512 bytes, still open
parser.parse
parser << "@"
parser.parse
# expected: expected ',' or ']' after array value at line 1 column 1005
# actual:   expected ',' or ']' after array value at line 1 column 4

Should the position be tracked across shrinks? Personally I'm not sure a position within a stream is very helpful, so I wonder if it would be fine to just drop it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions