From 58f4a676b5d740d5a2f8a1e17dc1901dc4a50c34 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Thu, 18 Jul 2024 22:44:33 +0200 Subject: [PATCH] fix json marshal --- backend/cmd/migration.go | 6 +++--- backend/service/config.go | 2 +- backend/sub/jsonService.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/cmd/migration.go b/backend/cmd/migration.go index 66b0158..df57af0 100644 --- a/backend/cmd/migration.go +++ b/backend/cmd/migration.go @@ -78,15 +78,15 @@ func migrateClientSchema(db *gorm.DB) error { switch cname { case "inbounds": inbounds := strings.Split(data.Data, ",") - newData, _ = json.MarshalIndent(inbounds, " ", " ") + newData, _ = json.MarshalIndent(inbounds, "", " ") case "config": jsonData := map[string]interface{}{} json.Unmarshal([]byte(data.Data), &jsonData) - newData, _ = json.MarshalIndent(jsonData, " ", " ") + newData, _ = json.MarshalIndent(jsonData, "", " ") case "links": jsonData := make([]interface{}, 0) json.Unmarshal([]byte(data.Data), &jsonData) - newData, _ = json.MarshalIndent(jsonData, " ", " ") + newData, _ = json.MarshalIndent(jsonData, "", " ") } err = db.Model(model.Client{}).Where("id = ?", data.Id).UpdateColumn(cname, newData).Error if err != nil { diff --git a/backend/service/config.go b/backend/service/config.go index c5f4e51..dd31a69 100644 --- a/backend/service/config.go +++ b/backend/service/config.go @@ -248,7 +248,7 @@ func (s *ConfigService) Save(singboxConfig *SingBoxConfig) error { return err } - data, err := json.MarshalIndent(singboxConfig, " ", " ") + data, err := json.MarshalIndent(singboxConfig, "", " ") if err != nil { return err } diff --git a/backend/sub/jsonService.go b/backend/sub/jsonService.go index 291c936..a7c331c 100644 --- a/backend/sub/jsonService.go +++ b/backend/sub/jsonService.go @@ -79,7 +79,7 @@ func (j *JsonService) GetJson(subId string, format string) (*string, error) { // Add other objects from settings j.addOthers(&jsonConfig) - result, _ := json.MarshalIndent(jsonConfig, " ", " ") + result, _ := json.MarshalIndent(jsonConfig, "", " ") resultStr := string(result) return &resultStr, nil }