This commit is contained in:
2022-06-16 22:19:06 +02:00
commit 085535931f
14 changed files with 812 additions and 0 deletions

24
codec/json.go Normal file
View File

@@ -0,0 +1,24 @@
package codec
import "encoding/json"
var (
JSON Codec = &jsonCodec{}
)
type jsonCodec struct{}
func (*jsonCodec) Name() string {
return "json"
}
func (*jsonCodec) Marshal(v any) ([]byte, error) {
return json.Marshal(v)
}
func (*jsonCodec) Unmarshal(b []byte, v any) error {
if len(b) == 0 {
return nil
}
return json.Unmarshal(b, v)
}