unmarsh增加忽略error

This commit is contained in:
白茶清欢 2023-12-24 20:54:39 +08:00
parent 2a8ebdc569
commit 01f39b6ea0

28
json.go
View File

@ -44,6 +44,15 @@ func (oj *ownJSON) UnmarshalWithNumber(byteData []byte, receiver interface{}) er
return decoder.Decode(receiver)
}
// UnmarshalWithNumberIgnoreError 反序列化且忽略error
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 20:46 2023/12/24
func (oj *ownJSON) UnmarshalWithNumberIgnoreError(byteData []byte, receiver interface{}) {
_ = oj.UnmarshalWithNumber(byteData, receiver)
}
// UnmarshalWithNumberForIOReader ...
//
// Author : go_developer@163.com<白茶清欢>
@ -55,6 +64,16 @@ func (oj *ownJSON) UnmarshalWithNumberForIOReader(ioReader io.ReadCloser, receiv
return decoder.Decode(receiver)
}
// UnmarshalWithNumberForIOReaderIgnoreError 反序列化忽略Error
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 20:47 2023/12/24
func (oj *ownJSON) UnmarshalWithNumberForIOReaderIgnoreError(ioReader io.ReadCloser, receiver interface{}) {
_ = oj.UnmarshalWithNumberForIOReader(ioReader, receiver)
return
}
// UnmarshalWithNumberForString 字符串转结构体
//
// Author : go_developer@163.com<白茶清欢>
@ -64,6 +83,15 @@ func (oj *ownJSON) UnmarshalWithNumberForString(input string, receiver interface
return oj.UnmarshalWithNumber([]byte(input), receiver)
}
// UnmarshalWithNumberForStringIgnoreError 反序列化并且忽略error
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 20:48 2023/12/24
func (oj *ownJSON) UnmarshalWithNumberForStringIgnoreError(input string, receiver interface{}) {
oj.UnmarshalWithNumberIgnoreError([]byte(input), receiver)
}
// MarshalForByte 序列化并返回字节数组
//
// Author : go_developer@163.com<白茶清欢>