️ 使用 json-iterator 替换 encoding/json 进行一些序列化/反序列化操作

This commit is contained in:
naiba
2022-03-18 23:13:22 +08:00
parent d928f65052
commit 3ca23d8d88
14 changed files with 46 additions and 37 deletions

View File

@@ -1,11 +1,11 @@
package model
import (
"encoding/json"
"fmt"
"html/template"
"time"
"github.com/naiba/nezha/pkg/utils"
pb "github.com/naiba/nezha/proto"
)
@@ -39,9 +39,9 @@ func (s *Server) CopyFromRunningServer(old *Server) {
}
func (s Server) Marshal() template.JS {
name, _ := json.Marshal(s.Name)
tag, _ := json.Marshal(s.Tag)
note, _ := json.Marshal(s.Note)
secret, _ := json.Marshal(s.Secret)
name, _ := utils.Json.Marshal(s.Name)
tag, _ := utils.Json.Marshal(s.Tag)
note, _ := utils.Json.Marshal(s.Note)
secret, _ := utils.Json.Marshal(s.Secret)
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":%s,"Secret":%s,"DisplayIndex":%d,"Tag":%s,"Note":%s}`, s.ID, name, secret, s.DisplayIndex, tag, note)) // #nosec
}