package
Version:
v1.0.14
Opens a new window with list of versions in this module.
Published: Mar 13, 2024
License: Apache-2.0
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
自定义json类型
一些带有特殊用途的类型
json string
json 字符串
使用场景:
import "gitee.com/novanest/toolkit/util/json"
var str = json.Val(`{"demo": true, "num": 123}`)
data := struct {
S Val
}{str}
json.Marshal(data) // {"S":{"demo":true,"num":123}}
data2 := struct{
Demo bool
Num int
}{}
str.JSON(&data2) // 也可以直接 json 反序列化
Documentation
¶
type JsonMap map[string]interface{}
JSONObj json 对象, 序列化的时候,变成纯字符串
Time 时间别名,在json序列化的时候,会格式成 2006-01-02 15:04:05 这种时间格式
结合 gorm 使用,存在数据库的是时间类型,转到接口的是上述时间格式
Val json 字符串
MarshalJSON 格式化为json字符串的时候,会格式化成 object
Source Files
¶
Click to show internal directories.
Click to hide internal directories.