fix codec.Frame in case of flatten struct tag
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
18
json.go
18
json.go
@@ -43,10 +43,6 @@ func (c *jsonCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, error)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if m, ok := v.(*codec.Frame); ok {
|
||||
return m.Data, nil
|
||||
}
|
||||
|
||||
options := c.opts
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
@@ -56,6 +52,10 @@ func (c *jsonCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, error)
|
||||
v = nv
|
||||
}
|
||||
|
||||
if m, ok := v.(*codec.Frame); ok {
|
||||
return m.Data, nil
|
||||
}
|
||||
|
||||
marshalOptions := DefaultMarshalOptions
|
||||
if options.Context != nil {
|
||||
if f, ok := options.Context.Value(marshalOptionsKey{}).(JsonMarshalOptions); ok {
|
||||
@@ -80,11 +80,6 @@ func (c *jsonCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option) err
|
||||
return nil
|
||||
}
|
||||
|
||||
if m, ok := v.(*codec.Frame); ok {
|
||||
m.Data = b
|
||||
return nil
|
||||
}
|
||||
|
||||
options := c.opts
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
@@ -94,6 +89,11 @@ func (c *jsonCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option) err
|
||||
v = nv
|
||||
}
|
||||
|
||||
if m, ok := v.(*codec.Frame); ok {
|
||||
m.Data = b
|
||||
return nil
|
||||
}
|
||||
|
||||
unmarshalOptions := DefaultUnmarshalOptions
|
||||
if options.Context != nil {
|
||||
if f, ok := options.Context.Value(unmarshalOptionsKey{}).(JsonUnmarshalOptions); ok {
|
||||
|
Reference in New Issue
Block a user