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

@@ -3,7 +3,6 @@ package main
import (
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io"
@@ -402,7 +401,7 @@ func handleTerminalTask(task *pb.Task) {
return
}
var terminal model.TerminalTask
err := json.Unmarshal([]byte(task.GetData()), &terminal)
err := utils.Json.Unmarshal([]byte(task.GetData()), &terminal)
if err != nil {
println("Terminal 任务解析错误:", err)
return
@@ -470,7 +469,7 @@ func handleTerminalTask(task *pb.Task) {
case 0:
io.Copy(tty, reader)
case 1:
decoder := json.NewDecoder(reader)
decoder := utils.Json.NewDecoder(reader)
var resizeMessage WindowSize
err := decoder.Decode(&resizeMessage)
if err != nil {

View File

@@ -1,7 +1,6 @@
package monitor
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
@@ -69,7 +68,7 @@ func fetchGeoIP(servers []string, isV6 bool) geoIP {
continue
}
resp.Body.Close()
err = json.Unmarshal(body, &ip)
err = utils.Json.Unmarshal(body, &ip)
if err != nil {
continue
}