From 01f39b6ea08d12f9e46de252115443454d5ef2ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 24 Dec 2023 20:54:39 +0800 Subject: [PATCH] =?UTF-8?q?unmarsh=E5=A2=9E=E5=8A=A0=E5=BF=BD=E7=95=A5erro?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- json.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/json.go b/json.go index c48d084..7edaf7f 100644 --- a/json.go +++ b/json.go @@ -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<白茶清欢>