File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -66,16 +66,12 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
6666 regex := `{ {.} }`
6767 regex = regexp.MustCompile("^\\/|\\/$").ReplaceAllString(regex, "$1") // Remove beginning slash and ending slash
6868 regex = regexp.MustCompile("\\\\(.)").ReplaceAllString(regex, "$1") // Remove duplicate escaping char for dots
69- rawString := strings.Trim(*dst.String, "\"")
69+ rawString := regexp.MustCompile(`^"|"$`).ReplaceAllString(*dst.String, "$1") // Remove quotes
70+ isMatched, _ := regexp.MatchString(regex, rawString)
7071 { {/pattern} }
71- if string(json{ {{.} }}) == "{ } " { // empty struct
72+ if string(json{ {{.} }}) == "{ } " { {#pattern } }|| !isMatched { {/pattern } } { // empty struct
7273 dst.{{#lambda.type-to-name} }{ {{.} }}{ {/lambda.type-to-name} } = nil
73- { {#pattern} }
74- } else if matched, _ := regexp.MatchString(regex, rawString); matched {
75- {{/pattern} }
76- { {^pattern} }
7774 } else {
78- {{/pattern} }
7975 match++
8076 }
8177 } else {
You can’t perform that action at this time.
0 commit comments