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:
Mikio Hara 2011-07-13 17:41:33 -07:00 committed by Russ Cox
parent 125e8277d5
commit 689a2ec8c3
3 changed files with 101 additions and 16 deletions

View file

@ -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}},