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

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-12-23 19:22:21 +03:00
parent f6d61d4cc8
commit aaedc8569a
4 changed files with 17 additions and 8 deletions

View File

@@ -58,6 +58,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
@@ -107,6 +111,11 @@ 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)
}
unmarshalOptions := DefaultUnmarshalOptions