From 93214633b8da5bc577886b194f470fcbf1323b0d Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 26 Aug 2021 12:22:20 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=89=B9=E6=80=A7=E3=80=91=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20cfg=20go=5Fjson=E5=8A=A8=E6=80=81=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=8C=96=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/TypeVisitors/GoDeserializeJsonUndering2Visitor.cs | 3 ++- .../Source/TypeVisitors/GoDeserializeJsonUnderingVisitor.cs | 3 ++- .../Source/TypeVisitors/GoDeserializeUnderingVisitor.cs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeJsonUndering2Visitor.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeJsonUndering2Visitor.cs index 3ae9f9b..b0f47ad 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeJsonUndering2Visitor.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeJsonUndering2Visitor.cs @@ -1,3 +1,4 @@ +using Luban.Job.Cfg.Datas; using Luban.Job.Common.Types; using Luban.Job.Common.TypeVisitors; @@ -86,7 +87,7 @@ namespace Luban.Job.Cfg.TypeVisitors public string Accept(TText type, string varName, string bufName) { - return DeserializeString(type, varName, bufName); + return $"{{var _ok_ bool; var __json_text__ map[string]interface{{}}; if __json_text__, _ok_ = {bufName}.(map[string]interface{{}}) ; !_ok_ {{ err = errors.New(\"{varName} error\"); return }}; {DeserializeString(type, "_", $"__json_text__[\"{DText.KEY_NAME}\"]")}; {DeserializeString(type, varName, $"__json_text__[\"{DText.TEXT_NAME}\"]")} }}"; } public string Accept(TBean type, string varName, string bufName) diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeJsonUnderingVisitor.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeJsonUnderingVisitor.cs index aac0f92..3087187 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeJsonUnderingVisitor.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeJsonUnderingVisitor.cs @@ -1,3 +1,4 @@ +using Luban.Job.Cfg.Datas; using Luban.Job.Common.Types; using Luban.Job.Common.TypeVisitors; @@ -86,7 +87,7 @@ namespace Luban.Job.Cfg.TypeVisitors public string Accept(TText type, string varName, string fieldName, string bufName) { - return DeserializeString(type, varName, fieldName, bufName); + return $"{{var _ok_ bool; var __json_text__ map[string]interface{{}}; if __json_text__, _ok_ = {bufName}[\"{fieldName}\"].(map[string]interface{{}}) ; !_ok_ {{ err = errors.New(\"{varName} error\"); return }}; {DeserializeString(type, "_", DText.KEY_NAME, "__json_text__")}; {DeserializeString(type, varName, DText.TEXT_NAME, "__json_text__")} }}"; } public string Accept(TBean type, string varName, string fieldName, string bufName) diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeUnderingVisitor.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeUnderingVisitor.cs index 4ca50f8..51dc13d 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeUnderingVisitor.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/GoDeserializeUnderingVisitor.cs @@ -74,7 +74,7 @@ namespace Luban.Job.Cfg.TypeVisitors public string Accept(TText type, string fieldName, string bufName) { - return $"{{ if {fieldName}, err = {bufName}.ReadString(); err != nil {{ return }} }}"; + return $"{{ if _, err = {bufName}.ReadString(); err != nil {{ return }}; if {fieldName}, err = {bufName}.ReadString(); err != nil {{ return }} }}"; } public string Accept(TBean type, string fieldName, string bufName)