Files
Go-http_framework/util/jsonEnhance/Json.go
T

34 lines
521 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* @Author : huangzj
* @Time : 2020/11/13 9:34
* @Description
*/
package jsonEnhance
import (
"github.com/json-iterator/go"
)
var (
//config 默认配置
config = jsoniter.ConfigFastest
)
func MarshalToString(v interface{}) string {
s, err := config.MarshalToString(v)
if err != nil {
panic(err)
}
return s
}
//UnmarshalFromString 直接从字符串反序列化
func UnmarshalFromString(str string, v interface{}) {
err := config.UnmarshalFromString(str, v)
if err != nil {
panic(err)
}
}