aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/v2/fields_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/json/v2/fields_test.go')
-rw-r--r--src/encoding/json/v2/fields_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/encoding/json/v2/fields_test.go b/src/encoding/json/v2/fields_test.go
index 1c36f80905..ae58182f29 100644
--- a/src/encoding/json/v2/fields_test.go
+++ b/src/encoding/json/v2/fields_test.go
@@ -503,6 +503,19 @@ func TestParseTagOptions(t *testing.T) {
wantOpts: fieldOptions{hasName: true, name: "-", quotedName: `"-"`},
wantErr: errors.New("Go struct field V has malformed `json` tag: invalid trailing ',' character"),
}, {
+ name: jsontest.Name("DashCommaOmitEmpty"),
+ in: struct {
+ V int `json:"-,omitempty"`
+ }{},
+ wantOpts: fieldOptions{hasName: true, name: "-", quotedName: `"-"`, omitempty: true},
+ wantErr: errors.New("Go struct field V has JSON object name \"-\"; either use `json:\"-\"` to ignore the field or use `json:\"'-',omitempty\"` to specify \"-\" as the name"),
+ }, {
+ name: jsontest.Name("QuotedDashCommaOmitEmpty"),
+ in: struct {
+ V int `json:"'-',omitempty"`
+ }{},
+ wantOpts: fieldOptions{hasName: true, name: "-", quotedName: `"-"`, omitempty: true},
+ }, {
name: jsontest.Name("QuotedDashName"),
in: struct {
V int `json:"'-'"`