1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00

struct to json

This commit is contained in:
2022-04-24 10:24:38 +08:00
parent 9c25f361d4
commit d3f727e54d

14
json/struct_json.go Normal file
View File

@ -0,0 +1,14 @@
package json
import "github.com/charlienet/go-mixed/bytesconv"
func StructToJsonIndent(obj interface{}) string {
b, _ := MarshalIndent(obj, "", " ")
return bytesconv.BytesToString(b)
}
// 结构转换为json字符串
func StructToJson(obj interface{}) string {
b, _ := Marshal(obj)
return bytesconv.BytesToString(b)
}