to struct

This commit is contained in:
白茶清欢 2023-06-02 16:43:18 +08:00
parent bb18c3cbfc
commit 4e24f1a655

View File

@ -115,3 +115,33 @@ func (ot *ObjectType) ToMapStringAny() ObjectResult {
res.Err = util.JSON.UnmarshalWithNumber(ot.byteData, &res.Value)
return res
}
// ToStruct ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 16:41 2023/6/2
func (ot *ObjectType) ToStruct(receiver interface{}) error {
if nil == receiver {
return errors.New("receiver is nil")
}
if ot.IsNil() {
return errors.New("data is nil")
}
return util.JSON.UnmarshalWithNumber(ot.byteData, receiver)
}
// ToStructIgnoreErr ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 16:42 2023/6/2
func (ot *ObjectType) ToStructIgnoreErr(receiver interface{}) {
if nil == receiver {
return
}
if ot.IsNil() {
return
}
_ = util.JSON.UnmarshalWithNumber(ot.byteData, receiver)
}