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

proposal: encoding/json: add access to the underlying data causing UnmarshalTypeError #22752

Open
buyology opened this Issue Nov 15, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@buyology

buyology commented Nov 15, 2017

Currently one has to maintain a copy of the data being decoded by json.Decoder to retrieve the underlying data yielding an UnmarshalTypeError when decoding a json stream.

Making the data in decodeState.data directly accessible in the returned error:

type UnmarshalTypeError struct {
    …
    Data    []byte
}

would make it easy to enable improved diagnostics for faulty inputs.

(Somewhat related to #8254 and #9693 which are also about error diagnostics in encoding/json.)

@bradfitz bradfitz changed the title from encoding/json: add access to the underlying data causing UnmarshalTypeError to proposal: encoding/json: add access to the underlying data causing UnmarshalTypeError Nov 15, 2017

@gopherbot gopherbot added this to the Proposal milestone Nov 16, 2017

@gopherbot gopherbot added the Proposal label Nov 16, 2017

@nathany

This comment has been minimized.

Contributor

nathany commented Nov 17, 2017

#6716 is also related and implemented

@rsc

This comment has been minimized.

Contributor

rsc commented Nov 20, 2017

On hold until next big encoding/json sweep.

@rsc rsc added the Proposal-Hold label Nov 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment