️ 使用 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

@@ -2,7 +2,6 @@ package controller
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
@@ -281,7 +280,7 @@ func (ma *memberAPI) addOrEditCron(c *gin.Context) {
cr.PushSuccessful = cf.PushSuccessful == "on"
cr.ID = cf.ID
cr.Cover = cf.Cover
err = json.Unmarshal([]byte(cf.ServersRaw), &cr.Servers)
err = utils.Json.Unmarshal([]byte(cf.ServersRaw), &cr.Servers)
}
tx := singleton.DB.Begin()
if err == nil {
@@ -433,7 +432,7 @@ func (ma *memberAPI) addOrEditAlertRule(c *gin.Context) {
var r model.AlertRule
err := c.ShouldBindJSON(&arf)
if err == nil {
err = json.Unmarshal([]byte(arf.RulesRaw), &r.Rules)
err = utils.Json.Unmarshal([]byte(arf.RulesRaw), &r.Rules)
}
if err == nil {
if len(r.Rules) == 0 {