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
}
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 {