add codec.RawMessage support
All checks were successful
test / test (push) Successful in 3m53s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-12-23 20:46:53 +03:00
parent 62db549d9a
commit 8e6ab14dd4
4 changed files with 31 additions and 171 deletions

View File

@@ -125,6 +125,10 @@ func (c *jsonCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, error)
return m.Data, nil
case *pb.Frame:
return m.Data, nil
case codec.RawMessage:
return []byte(m), nil
case *codec.RawMessage:
return []byte(*m), nil
}
marshalOptions := DefaultMarshalOptions
@@ -163,6 +167,12 @@ func (c *jsonCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option) err
case *pb.Frame:
m.Data = b
return nil
case *codec.RawMessage:
*m = append((*m)[0:0], b...)
return nil
case codec.RawMessage:
copy(m, b)
return nil
}
unmarshalOptions := DefaultUnmarshalOptions