物联网软件

This commit is contained in:
BBIT-Kai
2026-02-04 14:02:57 +08:00
parent 646e312a4c
commit 1c11f3f06c
28 changed files with 4526 additions and 271 deletions
+17
View File
@@ -1,6 +1,7 @@
package utils
import (
"encoding/json"
"fmt"
"net"
"os"
@@ -98,3 +99,19 @@ func GetDisk() string {
}
return fmt.Sprintf("%dGB", usage.Total/1024/1024/1024)
}
func PayloadToMap(payload []byte) (map[string]interface{}, error) {
var result map[string]interface{}
err := json.Unmarshal(payload, &result)
if err != nil {
return nil, err
}
return result, nil
}
func JSONToString(data map[string]interface{}) string {
jsonBytes, err := json.Marshal(data)
if err != nil {
return ""
}
return string(jsonBytes)
}