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) {