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)