From 7951e092387b602c781bc2bab9d665009e004d1f Mon Sep 17 00:00:00 2001 From: mappu Date: Mon, 27 Mar 2017 21:49:05 +1300 Subject: [PATCH] fixes for 5aad4b6dc90e --- config.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index 320b5da..3598c2d 100644 --- a/config.go +++ b/config.go @@ -26,13 +26,19 @@ type InputParam struct { Value string } -func (ip *InputParam) JSONUnmarshal(b []byte) error { - if b[0] == '"' { +func (ip *InputParam) UnmarshalJSON(b []byte) error { + switch b[0] { + case '"': ip.Description = "" ip.ParamType = PARAMTYPE_CONST - return json.Unmarshal(b, &ip.Value) + tmp := "" + err := json.Unmarshal(b, &tmp) + if err != nil { + return err + } + ip.Value = tmp - } else if b[0] == '{' { + case '{': read := struct { Description string `json:",omitempty"` ParamType ParamType @@ -45,9 +51,11 @@ func (ip *InputParam) JSONUnmarshal(b []byte) error { *ip = read return nil - } else { + default: return errors.New("Malformed InputParam") } + + return nil } type CommandConfig struct {