From 607a4887d0c5c6d92b402ae385cc4c6e21067cf8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 12 Aug 2021 15:43:51 +0800 Subject: [PATCH] 1 --- xobject.go | 3 ++- xvalue.go | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/xobject.go b/xobject.go index 875fb7e..5090ecd 100644 --- a/xobject.go +++ b/xobject.go @@ -1,6 +1,7 @@ package q5 import ( + "reflect" "net/url" "encoding/json" ) @@ -223,7 +224,7 @@ func (this *XObject) fromInterface(iVal interface{}) *XObject { this._type = XOT_SIMPLE this._val = NewXUndefined() if !this.AsXValue().TryFromInterface(iVal) { - panic("XObject.fromInterface type error2") + panic("XObject.fromInterface type error2 type" + reflect.TypeOf(iVal).String()) } } return this diff --git a/xvalue.go b/xvalue.go index 74e9584..60b7cf3 100644 --- a/xvalue.go +++ b/xvalue.go @@ -271,6 +271,11 @@ func (this *XValue) ToJsonInterface() interface{} { } func (this *XValue) TryFromInterface(val interface{}) bool { + if val == nil { + this._type = XVT_UNDEFINED + this._val = nil + return true + } switch val.(type) { case int8: this.SetInt8(val.(int8))