logic edit ,bug fix

This commit is contained in:
liuzhihang1
2025-02-13 10:35:34 +08:00
parent 65730ecb46
commit 5055cca3d9
6 changed files with 19 additions and 38 deletions

View File

@@ -83,3 +83,11 @@ func JsonStrToStruct[T any](str string) T {
json.Unmarshal([]byte(str), &data)
return data
}
func StructToJsonStr[T any](data T) string {
jsonStr, err := json.Marshal(data)
if err != nil {
return ""
}
return string(jsonStr)
}