forked from mirror/go-json
parent
3a4ad31980
commit
d9df77a119
|
@ -3907,3 +3907,14 @@ func TestIssue342(t *testing.T) {
|
||||||
t.Errorf("unexpected result: got(%v) != expected(%v)", got, expected)
|
t.Errorf("unexpected result: got(%v) != expected(%v)", got, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue360(t *testing.T) {
|
||||||
|
var uints []uint8
|
||||||
|
err := json.Unmarshal([]byte(`[0, 1, 2]`), &uints)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
if len(uints) != 3 || !(uints[0] == 0 && uints[1] == 1 && uints[2] == 2) {
|
||||||
|
t.Errorf("unexpected result: %v", uints)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,9 +23,8 @@ func byteUnmarshalerSliceDecoder(typ *runtime.Type, structName string, fieldName
|
||||||
unmarshalDecoder = newUnmarshalJSONDecoder(runtime.PtrTo(typ), structName, fieldName)
|
unmarshalDecoder = newUnmarshalJSONDecoder(runtime.PtrTo(typ), structName, fieldName)
|
||||||
case runtime.PtrTo(typ).Implements(unmarshalTextType):
|
case runtime.PtrTo(typ).Implements(unmarshalTextType):
|
||||||
unmarshalDecoder = newUnmarshalTextDecoder(runtime.PtrTo(typ), structName, fieldName)
|
unmarshalDecoder = newUnmarshalTextDecoder(runtime.PtrTo(typ), structName, fieldName)
|
||||||
}
|
default:
|
||||||
if unmarshalDecoder == nil {
|
unmarshalDecoder, _ = compileUint8(typ, structName, fieldName)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return newSliceDecoder(unmarshalDecoder, typ, 1, structName, fieldName)
|
return newSliceDecoder(unmarshalDecoder, typ, 1, structName, fieldName)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue