to struct
This commit is contained in:
parent
bb18c3cbfc
commit
4e24f1a655
30
object.go
30
object.go
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user