remove usage of gconv.Unsafe* functions internally to avoid unexpected errors

This commit is contained in:
John Guo
2021-09-14 19:30:20 +08:00
parent 99b6085235
commit 727f58a24b
32 changed files with 63 additions and 77 deletions

View File

@ -55,12 +55,12 @@ func (v *String) String() string {
// MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (v *String) MarshalJSON() ([]byte, error) {
return gconv.UnsafeStrToBytes(`"` + v.Val() + `"`), nil
return []byte(`"` + v.Val() + `"`), nil
}
// UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (v *String) UnmarshalJSON(b []byte) error {
v.Set(gconv.UnsafeBytesToStr(bytes.Trim(b, `"`)))
v.Set(string(bytes.Trim(b, `"`)))
return nil
}