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:
14
json/struct_json.go
Normal file
14
json/struct_json.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user