We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent db95112 commit 730ac5aCopy full SHA for 730ac5a
decoder_test.go
@@ -1451,3 +1451,25 @@ func TestDecoderExplicit(t *testing.T) {
1451
Equal(t, test.Name, "Joeybloggs")
1452
Equal(t, test.Age, 0)
1453
}
1454
+
1455
+func TestDecoderStructWithJSONTag(t *testing.T) {
1456
+ type Test struct {
1457
+ Name string `json:"name,omitempty"`
1458
+ Age int `json:",omitempty"`
1459
+ }
1460
1461
+ values := map[string][]string{
1462
+ "name": {"Joeybloggs"},
1463
+ "Age": {"3"},
1464
1465
1466
+ var test Test
1467
1468
+ d := NewDecoder()
1469
+ d.SetTagName("json")
1470
1471
+ err := d.Decode(&test, values)
1472
+ Equal(t, err, nil)
1473
+ Equal(t, test.Name, "Joeybloggs")
1474
+ Equal(t, test.Age, int(3))
1475
+}
0 commit comments