Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/json: UnmarshalTypeError should tell you what key you were unmarshaling #8254
As seen at http://stackoverflow.com/questions/24325210/get-field-name-that-errs-in-go-json-unmarshal, it would make it easier to debug JSON decoding errors, if UnmarshalTypeError would tell you which key you were unmarshaling when you encountered the type error.
I think it would be helpful here for json.UnmarshalTypeError to have a reference to the full set of bytes that were being unmarshalled, and the character location where the decoding failed. It could even print context lines with an extra line with a ^ character pointing to the problem character: