Skip to content

Commit 1c5cefe

Browse files
authored
json: accept ; in json field tag (#87)
Accept ; in `json` field tag to match the behavior of Go 1.16. https://go-review.googlesource.com/c/go/+/234818/4/src/encoding/json/encode.go Fixes #86
1 parent 61745d7 commit 1c5cefe

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

json/codec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ func isValidTag(s string) bool {
844844
}
845845
for _, c := range s {
846846
switch {
847-
case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c):
847+
case strings.ContainsRune("!#$%&()*+-./:;<=>?@[]^_{|}~ ", c):
848848
// Backslash and quote chars are reserved, but
849849
// otherwise any punctuation chars are allowed
850850
// in a tag name.

json/golang_tagkey_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type percentSlashTag struct {
4141
}
4242

4343
type punctuationTag struct {
44-
V string `json:"!#$%&()*+-./:<=>?@[]^_{|}~"` // https://golang.org/issue/3546
44+
V string `json:"!#$%&()*+-./:;<=>?@[]^_{|}~"` // https://golang.org/issue/3546
4545
}
4646

4747
type dashTag struct {
@@ -90,7 +90,7 @@ var structTagObjectKeyTests = []struct {
9090
{badFormatTag{"Orfevre"}, "Orfevre", "Y"},
9191
{badCodeTag{"Reliable Man"}, "Reliable Man", "Z"},
9292
{percentSlashTag{"brut"}, "brut", "text/html%"},
93-
{punctuationTag{"Union Rags"}, "Union Rags", "!#$%&()*+-./:<=>?@[]^_{|}~"},
93+
{punctuationTag{"Union Rags"}, "Union Rags", "!#$%&()*+-./:;<=>?@[]^_{|}~"},
9494
{spaceTag{"Perreddu"}, "Perreddu", "With space"},
9595
{unicodeTag{"Loukanikos"}, "Loukanikos", "Ελλάδα"},
9696
}

0 commit comments

Comments
 (0)