3 Commits

Author SHA1 Message Date
f250aeb50d update to latest micro
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-17 17:36:45 +03:00
b19b8813b6 update to latest micro
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-17 13:03:21 +03:00
0476b2dd5c update to latest micro, optimize flatten
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-17 12:31:43 +03:00
2 changed files with 8 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ func TestFrameFlatten(t *testing.T) {
Name: &codec.Frame{Data: []byte("test")}, Name: &codec.Frame{Data: []byte("test")},
} }
buf, err := NewCodec().Marshal(s) buf, err := NewCodec(codec.Flatten(true)).Marshal(s)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -20,8 +20,8 @@ var (
) )
var ( var (
_ codec.Codec = (*jsonCodec)() _ codec.Codec = (*jsonCodec)(nil)
_ codec.CodecV2 = (*jsonCodecV2)() _ codec.CodecV2 = (*jsonCodecV2)(nil)
) )
type JsonMarshalOptions struct { type JsonMarshalOptions struct {
@@ -211,7 +211,7 @@ func (c *jsonCodecV2) Marshal(b []byte, v interface{}, opts ...codec.Option) ([]
} }
var err error var err error
b, err = json.Append(b, v, getMarshalFlags(marshalOptions)) b, err = json.Append(b[:0], v, getMarshalFlags(marshalOptions))
return b, err return b, err
} }
@@ -258,3 +258,7 @@ func (c *jsonCodecV2) String() string {
func NewCodec(opts ...codec.Option) *jsonCodec { func NewCodec(opts ...codec.Option) *jsonCodec {
return &jsonCodec{opts: codec.NewOptions(opts...)} return &jsonCodec{opts: codec.NewOptions(opts...)}
} }
func NewCodecV2(opts ...codec.Option) *jsonCodecV2 {
return &jsonCodecV2{opts: codec.NewOptions(opts...)}
}