mirror of
https://github.com/pyihe/go-pkg.git
synced 2025-10-07 08:50:51 +08:00
style(go-pkg): rename pkg
This commit is contained in:
17
serialize/json.go
Normal file
17
serialize/json.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package serialize
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type jsonSerializer struct{}
|
||||
|
||||
func JSON() Serializer {
|
||||
return jsonSerializer{}
|
||||
}
|
||||
|
||||
func (js jsonSerializer) Encode(v interface{}) (data []byte, err error) {
|
||||
return json.Marshal(v)
|
||||
}
|
||||
|
||||
func (js jsonSerializer) Decode(data []byte, v interface{}) error {
|
||||
return json.Unmarshal(data, v)
|
||||
}
|
Reference in New Issue
Block a user