2025-06-19 10:33:58 +08:00

26 lines
500 B
Go

package json
import (
"fmt"
jsoniter "github.com/json-iterator/go"
)
var (
json = jsoniter.ConfigCompatibleWithStandardLibrary
Marshal = json.Marshal
Unmarshal = json.Unmarshal
MarshalIndent = json.MarshalIndent
NewDecoder = json.NewDecoder
NewEncoder = json.NewEncoder
)
func MarshalToString(v interface{}) string {
s, err := jsoniter.MarshalToString(v)
if err != nil {
fmt.Println("Failed to marshal json string: " + err.Error())
return ""
}
return s
}