15 lines
260 B
Go
15 lines
260 B
Go
package codec
|
|
|
|
import "encoding/json"
|
|
|
|
type jsonCodec struct{}
|
|
|
|
var JSON = jsonCodec{}
|
|
|
|
func (jsonCodec) Decode(data []byte, out any) error {
|
|
return json.Unmarshal(data, out)
|
|
}
|
|
|
|
func (jsonCodec) Encode(data any) ([]byte, error) {
|
|
return json.Marshal(data)
|
|
}
|