From a565e8082441090ed8caace29f027253c1aeb536 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 15 Nov 2022 11:30:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0redis=20=E8=A7=A3=E7=A0=81?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/utils/codec/factory/factory_map.go | 2 +- lego/utils/codec/factory/factory_struct.go | 5 +++++ lego/utils/codec/json/reader.go | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lego/utils/codec/factory/factory_map.go b/lego/utils/codec/factory/factory_map.go index eac42c436..55f5561a3 100644 --- a/lego/utils/codec/factory/factory_map.go +++ b/lego/utils/codec/factory/factory_map.go @@ -279,7 +279,7 @@ func (this *mapDecoder) Decode(ptr unsafe.Pointer, extra codecore.IReader) { return } if extra.CheckNextIsObjectEnd() { - extra.ReadObjectEnd() + // extra.ReadObjectEnd() return } key := this.keyType.UnsafeNew() diff --git a/lego/utils/codec/factory/factory_struct.go b/lego/utils/codec/factory/factory_struct.go index 03efeb622..3b17b4230 100644 --- a/lego/utils/codec/factory/factory_struct.go +++ b/lego/utils/codec/factory/factory_struct.go @@ -307,6 +307,11 @@ func (this *structDecoder) Decode(ptr unsafe.Pointer, r codecore.IReader) { if !r.ReadObjectStart() { return } + + if r.CheckNextIsObjectEnd() { //空对象直接跳出 + return + } + this.decodeField(ptr, r) for r.ReadMemberSplit() { this.decodeField(ptr, r) diff --git a/lego/utils/codec/json/reader.go b/lego/utils/codec/json/reader.go index 8753ae351..a19a64e5b 100644 --- a/lego/utils/codec/json/reader.go +++ b/lego/utils/codec/json/reader.go @@ -141,10 +141,10 @@ func (this *JsonReader) ReadObjectStart() (ret bool) { } func (this *JsonReader) CheckNextIsObjectEnd() (ret bool) { c := this.nextToken() - this.unreadByte() if c == '}' { - return true + return this.decrementDepth() } + this.unreadByte() return } func (this *JsonReader) ReadObjectEnd() (ret bool) {