Skip to content

encoding/json/v2: Decoder.More() == false on syntax error #76467

@neild

Description

@neild
dec := json.NewDecoder(strings.NewReader(","))
fmt.Println(dec.More())
fmt.Println(dec.Token())
$ go run .
true
<nil> invalid character ',' looking for beginning of value
$ GOEXPERIMENT=jsonv2 go run .
false
<nil> invalid character ',' looking for beginning of value

The JSONv1 implementation of More reports false if there is an error filling its buffer, but it reports true if the next token is semantically invalid. JSONv2 appears to report false if the next token is invalid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions