mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
encoding/json: add embedded structs to the UnmarshalTypeError's Field
Including embedded struct inforamtion in error message.
Fixes #68941
Change-Id: I6a6f7d506104839a9a7cf1a2c3003272f5534a79
GitHub-Last-Rev: 717f680aca
GitHub-Pull-Request: golang/go#68966
Reviewed-on: https://go-review.googlesource.com/c/go/+/606956
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
parent
3da6c94d5e
commit
0fe6347732
3 changed files with 27 additions and 7 deletions
|
|
@ -898,6 +898,19 @@ var unmarshalTests = []struct {
|
|||
},
|
||||
},
|
||||
|
||||
{
|
||||
CaseName: Name(""),
|
||||
in: `{"Level1a": "hello"}`,
|
||||
ptr: new(Top),
|
||||
err: &UnmarshalTypeError{
|
||||
Value: "string",
|
||||
Struct: "Top",
|
||||
Field: "Embed0a.Level1a",
|
||||
Type: reflect.TypeFor[int](),
|
||||
Offset: 10,
|
||||
},
|
||||
},
|
||||
|
||||
// issue 15146.
|
||||
// invalid inputs in wrongStringTests below.
|
||||
{CaseName: Name(""), in: `{"B":"true"}`, ptr: new(B), out: B{true}, golden: true},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue