1
0
mirror of https://github.com/json-iterator/go.git synced 2025-11-26 22:40:13 +02:00

#68 empty array to object/map

This commit is contained in:
Tao Wen
2017-06-20 16:36:22 +08:00
parent 086001225d
commit 85be06b145
4 changed files with 84 additions and 6 deletions

View File

@@ -85,3 +85,17 @@ func Test_float_to_float64(t *testing.T) {
should.Nil(jsoniter.UnmarshalFromString(`1.23`, &val))
should.Equal(float64(1.23), val)
}
func Test_empty_array_as_map(t *testing.T) {
should := require.New(t)
var val map[string]interface{}
should.Nil(jsoniter.UnmarshalFromString(`[]`, &val))
should.Equal(map[string]interface{}{}, val)
}
func Test_empty_array_as_object(t *testing.T) {
should := require.New(t)
var val struct{}
should.Nil(jsoniter.UnmarshalFromString(`[]`, &val))
should.Equal(struct{}{}, val)
}