system text format changes

This commit is contained in:
Gordon
2021-05-27 11:40:39 +08:00
parent 32d5e1515c
commit 4ff8a75b3f
5 changed files with 32 additions and 5 deletions
+25
View File
@@ -0,0 +1,25 @@
/*
** description("").
** copyright('open-im,www.open-im.io').
** author("fg,Gordon@tuoyun.net").
** time(2021/5/27 11:24).
*/
package content_struct
import "encoding/json"
type Content struct {
IsDisplay int32 `json:"isDisplay"`
ID string `json:"id"`
Text string `json:"text"`
}
func NewContentStructString(isDisplay int32, ID string, text string) string {
c := Content{IsDisplay: isDisplay, ID: ID, Text: text}
return c.contentToString()
}
func (c *Content) contentToString() string {
data, _ := json.Marshal(c)
dataString := string(data)
return dataString
}