Skip to content
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

@buyology
Copy link

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 encoding/json: add access to the underlying data causing UnmarshalTypeError 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
@nathany
Copy link
Contributor

nathany commented Nov 17, 2017

#6716 is also related and implemented

@rsc
Copy link
Contributor

rsc commented Nov 20, 2017

On hold until next big encoding/json sweep.

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

No branches or pull requests

4 participants