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 {