mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 12:17:53 +08:00
add MustEncode for package gjson
This commit is contained in:
parent
b79e4a3ab7
commit
984e5f98f7
@ -25,6 +25,15 @@ func Encode(value interface{}) ([]byte, error) {
|
||||
return json.Marshal(value)
|
||||
}
|
||||
|
||||
// MustEncode performs as Encode, but it panics if any error occurs.
|
||||
func MustEncode(value interface{}) []byte {
|
||||
b, err := Encode(value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Decode decodes json format `data` to golang variable.
|
||||
// The parameter `data` can be either bytes or string type.
|
||||
func Decode(data interface{}) (interface{}, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user