add MustEncodeString for package gjson

This commit is contained in:
John Guo 2021-12-26 14:42:09 +08:00
parent 984e5f98f7
commit ca5c0cc84d

View File

@ -34,6 +34,12 @@ func MustEncode(value interface{}) []byte {
return b
}
// MustEncodeString encodes any golang variable `value` to JSON string.
// It panics if any error occurs.
func MustEncodeString(value interface{}) string {
return string(MustEncode(value))
}
// Decode decodes json format `data` to golang variable.
// The parameter `data` can be either bytes or string type.
func Decode(data interface{}) (interface{}, error) {