[subjson] avoid array for one config

This commit is contained in:
Alireza Ahmadi
2024-03-28 14:12:16 +01:00
parent de6c768149
commit a090c6d6e7

View File

@@ -127,7 +127,12 @@ func (s *SubJsonService) GetJson(subId string, host string) (string, string, err
}
// Combile outbounds
finalJson, _ := json.MarshalIndent(configArray, "", " ")
var finalJson []byte
if len(configArray) == 1 {
finalJson, _ = json.MarshalIndent(configArray[0], "", " ")
} else {
finalJson, _ = json.MarshalIndent(configArray, "", " ")
}
header = fmt.Sprintf("upload=%d; download=%d; total=%d; expire=%d", traffic.Up, traffic.Down, traffic.Total, traffic.ExpiryTime/1000)
return string(finalJson), header, nil