From cd4e1b4789c549d89aa159a82a694a0d7bbd22e4 Mon Sep 17 00:00:00 2001 From: what Date: Mon, 31 Jul 2023 20:48:24 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E7=A7=BB=E9=99=A4=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=20ToValue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/res_field.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/base/res_field.go b/base/res_field.go index beecea0..4e223fe 100644 --- a/base/res_field.go +++ b/base/res_field.go @@ -1,7 +1,6 @@ package base import ( - "encoding/json" "fmt" "reflect" "strconv" @@ -117,17 +116,17 @@ func (this ResField) ToValue(v any) any { case contracts.ResDataType_Json: if v == nil { if this.Default != "" && this.Default[0:1] == "[" { - return "[]" + return db.Raw("'[]'") } else if this.Default != "" && this.Default[0:1] == "{" { - return "{}" + return db.Raw("'{}'") } else if this.Default == "" { - return "{}" + return db.Raw("'{}'") } return this.Default } - b, _ := json.Marshal(v) - return string(b) + + return v } return strings.Trim(cast.ToString(v), " ")