fix: panic on convert to string on fillSliceFromString() (#1951)

* Update unmarshaler.go

 fix: 修复fillSliceFromString()方法中mapValue 强转string后的panic 错误

* test: 增加单元测试

增加单元测试

* Update unmarshaler_test.go
This commit is contained in:
家福
2022-06-03 00:27:48 +08:00
committed by GitHub
parent 321a20add6
commit 07145b210e
2 changed files with 20 additions and 2 deletions

View File

@@ -2789,3 +2789,14 @@ func BenchmarkDefaultValue(b *testing.B) {
}
}
}
func TestUnmarshalJsonReaderArray(t *testing.T) {
payload := "{\"id\": 123}"
var res struct {
ID []string `json:"id"`
}
reader := strings.NewReader(payload)
err := UnmarshalJsonReader(reader, &res)
assert.Nil(t, err)
assert.Equal(t, 1, len(res.ID))
}