mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
json: allow using '$' and '-' as the struct field's tag
R=adg, rsc, bradfitz, mattn.jp, gustavo CC=golang-dev https://golang.org/cl/4625081
This commit is contained in:
parent
125e8277d5
commit
689a2ec8c3
3 changed files with 101 additions and 16 deletions
|
|
@ -40,13 +40,6 @@ var (
|
|||
umtrue = unmarshaler{true}
|
||||
)
|
||||
|
||||
type badTag struct {
|
||||
X string
|
||||
Y string `json:"y"`
|
||||
Z string `x:"@#*%(#@"`
|
||||
W string `json:"@#$@#$"`
|
||||
}
|
||||
|
||||
type unmarshalTest struct {
|
||||
in string
|
||||
ptr interface{}
|
||||
|
|
@ -68,9 +61,6 @@ var unmarshalTests = []unmarshalTest{
|
|||
{`{"X": [1,2,3], "Y": 4}`, new(T), T{Y: 4}, &UnmarshalTypeError{"array", reflect.TypeOf("")}},
|
||||
{`{"x": 1}`, new(tx), tx{}, &UnmarshalFieldError{"x", txType, txType.Field(0)}},
|
||||
|
||||
// skip invalid tags
|
||||
{`{"X":"a", "y":"b", "Z":"c", "W":"d"}`, new(badTag), badTag{"a", "b", "c", "d"}, nil},
|
||||
|
||||
// syntax errors
|
||||
{`{"X": "foo", "Y"}`, nil, nil, &SyntaxError{"invalid character '}' after object key", 17}},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue