1 Star 0 Fork 0

liujinsuo/tool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
with_json2.go 476 Bytes
一键复制 编辑 原始数据 按行查看 历史
liujinsuo 提交于 2年前 . JSON2
package tool
import "github.com/goccy/go-json"
// JSON2 包装一个类型使其直json编解码
// 可用于 go-redis set一个struct 或 scan
type JSON2 struct {
v any
}
func WithJSON2(v any) *JSON2 {
return &JSON2{
v: v,
}
}
// UnmarshalBinary 解码函数
func (s *JSON2) UnmarshalBinary(data []byte) error {
return json.Unmarshal(data, s.v)
}
// MarshalBinary 编码函数
func (s *JSON2) MarshalBinary() (data []byte, err error) {
return json.Marshal(s.v)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/liujinsuo/tool.git
git@gitee.com:liujinsuo/tool.git
liujinsuo
tool
tool
537076f1d965

搜索帮助