fix nil target (#774)

pull/781/head
Tony Chen 4 years ago committed by GitHub
parent 0b93bef031
commit 32f7322b82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      encoding/json/json.go

@ -24,7 +24,7 @@ func (codec) Marshal(v interface{}) ([]byte, error) {
func (codec) Unmarshal(data []byte, v interface{}) error { func (codec) Unmarshal(data []byte, v interface{}) error {
rv := reflect.ValueOf(v) rv := reflect.ValueOf(v)
for rv.Kind() == reflect.Ptr { for rv.Kind() == reflect.Ptr {
if rv.IsNil() && rv.CanSet() { if rv.IsNil() && rv.CanInterface() {
rv.Set(reflect.New(rv.Type().Elem())) rv.Set(reflect.New(rv.Type().Elem()))
v = rv.Interface() v = rv.Interface()
} }

Loading…
Cancel
Save