|
|
@ -39,7 +39,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 := rv; rv.Kind() == reflect.Ptr; { |
|
|
|
if rv.IsNil() { |
|
|
|
if rv.IsNil() { |
|
|
|
rv.Set(reflect.New(rv.Type().Elem())) |
|
|
|
rv.Set(reflect.New(rv.Type().Elem())) |
|
|
|
} |
|
|
|
} |
|
|
@ -47,7 +47,7 @@ func (codec) Unmarshal(data []byte, v interface{}) error { |
|
|
|
} |
|
|
|
} |
|
|
|
if m, ok := v.(proto.Message); ok { |
|
|
|
if m, ok := v.(proto.Message); ok { |
|
|
|
return UnmarshalOptions.Unmarshal(data, m) |
|
|
|
return UnmarshalOptions.Unmarshal(data, m) |
|
|
|
} else if m, ok := reflect.Indirect(reflect.ValueOf(v)).Interface().(proto.Message); ok { |
|
|
|
} else if m, ok := reflect.Indirect(rv).Interface().(proto.Message); ok { |
|
|
|
return UnmarshalOptions.Unmarshal(data, m) |
|
|
|
return UnmarshalOptions.Unmarshal(data, m) |
|
|
|
} |
|
|
|
} |
|
|
|
return json.Unmarshal(data, v) |
|
|
|
return json.Unmarshal(data, v) |
|
|
|