2023-05-05 23:23:34 +08:00
|
|
|
package backend_golang
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2023-05-06 20:17:39 +08:00
|
|
|
func (a *App) SaveJson(fileName string, jsonData interface{}) string {
|
|
|
|
text, err := json.MarshalIndent(jsonData, "", " ")
|
2023-05-05 23:23:34 +08:00
|
|
|
if err != nil {
|
|
|
|
return err.Error()
|
|
|
|
}
|
|
|
|
|
2023-05-06 20:17:39 +08:00
|
|
|
if err := os.WriteFile(fileName, text, 0644); err != nil {
|
2023-05-05 23:23:34 +08:00
|
|
|
return err.Error()
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|