1 Star 0 Fork 0

jmesyan / impetus

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
json.go 564 Bytes
一键复制 编辑 原始数据 按行查看 历史
jmesyan 提交于 2020-12-12 22:03 . init
package json
import (
"github.com/json-iterator/go"
)
type JsonCodec struct {
}
func NewCodec() *JsonCodec {
p := new(JsonCodec)
return p
}
// goroutine safe
func (p *JsonCodec) Unmarshal(obj interface{}, data []byte) error {
var json = jsoniter.ConfigCompatibleWithStandardLibrary
err := json.Unmarshal(data, obj)
if err != nil {
return err
}
return nil
}
// goroutine safe
func (p *JsonCodec) Marshal(msg interface{}) ([]byte, error) {
var json = jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.Marshal(msg)
return data, err
}
Go
1
https://gitee.com/jmesyan/impetus.git
git@gitee.com:jmesyan/impetus.git
jmesyan
impetus
impetus
v1.1.4

搜索帮助