fixes for 5aad4b6dc90e

This commit is contained in:
mappu 2017-03-27 21:49:05 +13:00
parent eab781794e
commit 7951e09238
1 changed files with 13 additions and 5 deletions

View File

@ -26,13 +26,19 @@ type InputParam struct {
Value string Value string
} }
func (ip *InputParam) JSONUnmarshal(b []byte) error { func (ip *InputParam) UnmarshalJSON(b []byte) error {
if b[0] == '"' { switch b[0] {
case '"':
ip.Description = "" ip.Description = ""
ip.ParamType = PARAMTYPE_CONST 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 { read := struct {
Description string `json:",omitempty"` Description string `json:",omitempty"`
ParamType ParamType ParamType ParamType
@ -45,9 +51,11 @@ func (ip *InputParam) JSONUnmarshal(b []byte) error {
*ip = read *ip = read
return nil return nil
} else { default:
return errors.New("Malformed InputParam") return errors.New("Malformed InputParam")
} }
return nil
} }
type CommandConfig struct { type CommandConfig struct {