mirror of
https://github.com/nitezs/sub2sing-box.git
synced 2024-12-25 01:14:42 -05:00
26 lines
505 B
Go
26 lines
505 B
Go
|
package util
|
||
|
|
||
|
import "encoding/json"
|
||
|
|
||
|
func MergeAndMarshal(args ...interface{}) (string, error) {
|
||
|
merged := make(map[string]interface{})
|
||
|
for _, arg := range args {
|
||
|
jsonBytes, err := json.Marshal(arg)
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
var m map[string]interface{}
|
||
|
if err := json.Unmarshal(jsonBytes, &m); err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
for k, v := range m {
|
||
|
merged[k] = v
|
||
|
}
|
||
|
}
|
||
|
result, err := json.Marshal(merged)
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
return string(result), nil
|
||
|
}
|