fix json marshal
This commit is contained in:
@@ -78,15 +78,15 @@ func migrateClientSchema(db *gorm.DB) error {
|
|||||||
switch cname {
|
switch cname {
|
||||||
case "inbounds":
|
case "inbounds":
|
||||||
inbounds := strings.Split(data.Data, ",")
|
inbounds := strings.Split(data.Data, ",")
|
||||||
newData, _ = json.MarshalIndent(inbounds, " ", " ")
|
newData, _ = json.MarshalIndent(inbounds, "", " ")
|
||||||
case "config":
|
case "config":
|
||||||
jsonData := map[string]interface{}{}
|
jsonData := map[string]interface{}{}
|
||||||
json.Unmarshal([]byte(data.Data), &jsonData)
|
json.Unmarshal([]byte(data.Data), &jsonData)
|
||||||
newData, _ = json.MarshalIndent(jsonData, " ", " ")
|
newData, _ = json.MarshalIndent(jsonData, "", " ")
|
||||||
case "links":
|
case "links":
|
||||||
jsonData := make([]interface{}, 0)
|
jsonData := make([]interface{}, 0)
|
||||||
json.Unmarshal([]byte(data.Data), &jsonData)
|
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
|
err = db.Model(model.Client{}).Where("id = ?", data.Id).UpdateColumn(cname, newData).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ func (s *ConfigService) Save(singboxConfig *SingBoxConfig) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := json.MarshalIndent(singboxConfig, " ", " ")
|
data, err := json.MarshalIndent(singboxConfig, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ func (j *JsonService) GetJson(subId string, format string) (*string, error) {
|
|||||||
// Add other objects from settings
|
// Add other objects from settings
|
||||||
j.addOthers(&jsonConfig)
|
j.addOthers(&jsonConfig)
|
||||||
|
|
||||||
result, _ := json.MarshalIndent(jsonConfig, " ", " ")
|
result, _ := json.MarshalIndent(jsonConfig, "", " ")
|
||||||
resultStr := string(result)
|
resultStr := string(result)
|
||||||
return &resultStr, nil
|
return &resultStr, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user