|
|
@@ -2,7 +2,6 @@ package costmodel
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
- "encoding/json"
|
|
|
"flag"
|
|
|
"fmt"
|
|
|
"net/http"
|
|
|
@@ -39,6 +38,7 @@ import (
|
|
|
"k8s.io/client-go/kubernetes"
|
|
|
"k8s.io/client-go/rest"
|
|
|
"k8s.io/client-go/tools/clientcmd"
|
|
|
+ jsoniter "github.com/json-iterator/go"
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
@@ -308,14 +308,14 @@ func WrapData(data interface{}, err error) []byte {
|
|
|
|
|
|
if err != nil {
|
|
|
klog.V(1).Infof("Error returned to client: %s", err.Error())
|
|
|
- resp, _ = json.Marshal(&Response{
|
|
|
+ resp, _ = jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(&Response{
|
|
|
Code: http.StatusInternalServerError,
|
|
|
Status: "error",
|
|
|
Message: err.Error(),
|
|
|
Data: data,
|
|
|
})
|
|
|
} else {
|
|
|
- resp, _ = json.Marshal(&Response{
|
|
|
+ resp, _ = jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(&Response{
|
|
|
Code: http.StatusOK,
|
|
|
Status: "success",
|
|
|
Data: data,
|
|
|
@@ -330,14 +330,14 @@ func WrapDataWithMessage(data interface{}, err error, message string) []byte {
|
|
|
|
|
|
if err != nil {
|
|
|
klog.V(1).Infof("Error returned to client: %s", err.Error())
|
|
|
- resp, _ = json.Marshal(&Response{
|
|
|
+ resp, _ = jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(&Response{
|
|
|
Code: http.StatusInternalServerError,
|
|
|
Status: "error",
|
|
|
Message: err.Error(),
|
|
|
Data: data,
|
|
|
})
|
|
|
} else {
|
|
|
- resp, _ = json.Marshal(&Response{
|
|
|
+ resp, _ = jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(&Response{
|
|
|
Code: http.StatusOK,
|
|
|
Status: "success",
|
|
|
Data: data,
|
|
|
@@ -353,7 +353,7 @@ func WrapDataWithWarning(data interface{}, err error, warning string) []byte {
|
|
|
|
|
|
if err != nil {
|
|
|
klog.V(1).Infof("Error returned to client: %s", err.Error())
|
|
|
- resp, _ = json.Marshal(&Response{
|
|
|
+ resp, _ = jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(&Response{
|
|
|
Code: http.StatusInternalServerError,
|
|
|
Status: "error",
|
|
|
Message: err.Error(),
|
|
|
@@ -361,7 +361,7 @@ func WrapDataWithWarning(data interface{}, err error, warning string) []byte {
|
|
|
Data: data,
|
|
|
})
|
|
|
} else {
|
|
|
- resp, _ = json.Marshal(&Response{
|
|
|
+ resp, _ = jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(&Response{
|
|
|
Code: http.StatusOK,
|
|
|
Status: "success",
|
|
|
Data: data,
|
|
|
@@ -377,7 +377,7 @@ func WrapDataWithMessageAndWarning(data interface{}, err error, message, warning
|
|
|
|
|
|
if err != nil {
|
|
|
klog.V(1).Infof("Error returned to client: %s", err.Error())
|
|
|
- resp, _ = json.Marshal(&Response{
|
|
|
+ resp, _ = jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(&Response{
|
|
|
Code: http.StatusInternalServerError,
|
|
|
Status: "error",
|
|
|
Message: err.Error(),
|
|
|
@@ -385,7 +385,7 @@ func WrapDataWithMessageAndWarning(data interface{}, err error, message, warning
|
|
|
Data: data,
|
|
|
})
|
|
|
} else {
|
|
|
- resp, _ = json.Marshal(&Response{
|
|
|
+ resp, _ = jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(&Response{
|
|
|
Code: http.StatusOK,
|
|
|
Status: "success",
|
|
|
Data: data,
|