diff --git a/json/struct_json.go b/json/struct_json.go new file mode 100644 index 0000000..a090170 --- /dev/null +++ b/json/struct_json.go @@ -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) +}