fixup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
047c791f3b
commit
cfd576d197
23
jsonpb.go
23
jsonpb.go
@ -39,16 +39,17 @@ func (c *jsonpbCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, erro
|
||||
case *codec.Frame:
|
||||
return m.Data, nil
|
||||
case proto.Message:
|
||||
if nv, nerr := rutil.StructFieldByTag(m, codec.DefaultTagName, flattenTag); nerr == nil {
|
||||
if nm, ok := nv.(proto.Message); ok {
|
||||
m = nm
|
||||
}
|
||||
}
|
||||
options := c.opts
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
if nv, nerr := rutil.StructFieldByTag(m, options.TagName, flattenTag); nerr == nil {
|
||||
if nm, ok := nv.(proto.Message); ok {
|
||||
m = nm
|
||||
}
|
||||
}
|
||||
|
||||
marshalOptions := DefaultMarshalOptions
|
||||
if options.Context != nil {
|
||||
if f, ok := options.Context.Value(marshalOptionsKey{}).(jsonpb.MarshalOptions); ok {
|
||||
@ -72,17 +73,17 @@ func (c *jsonpbCodec) Unmarshal(d []byte, v interface{}, opts ...codec.Option) e
|
||||
m.Data = d
|
||||
return nil
|
||||
case proto.Message:
|
||||
if nv, nerr := rutil.StructFieldByTag(m, codec.DefaultTagName, flattenTag); nerr == nil {
|
||||
if nm, ok := nv.(proto.Message); ok {
|
||||
m = nm
|
||||
}
|
||||
}
|
||||
|
||||
options := c.opts
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
if nv, nerr := rutil.StructFieldByTag(m, options.TagName, flattenTag); nerr == nil {
|
||||
if nm, ok := nv.(proto.Message); ok {
|
||||
m = nm
|
||||
}
|
||||
}
|
||||
|
||||
unmarshalOptions := DefaultUnmarshalOptions
|
||||
if options.Context != nil {
|
||||
if f, ok := options.Context.Value(unmarshalOptionsKey{}).(jsonpb.UnmarshalOptions); ok {
|
||||
|
Loading…
x
Reference in New Issue
Block a user