Skip to content

Commit

Permalink
improve unmarshal support for string lists presented as a single stri…
Browse files Browse the repository at this point in the history
…ng, which occurs in some places (!)
  • Loading branch information
crewjam committed Aug 12, 2016
1 parent 12233c7 commit 10b532f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions string_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ func (x *StringListExpr) UnmarshalJSON(data []byte) error {
return fmt.Errorf("%#v is not a StringListFunc", funcCall)
}

// Perhaps we have a single item, like "foo" which
// occurs occasionally.
var v2 StringExpr
err3 := json.Unmarshal(data, &v2)
if err3 == nil {
x.Func = nil
x.Literal = []*StringExpr{&v2}
return nil
}

// Return the original error trying to unmarshal the literal expression,
// which will be the most expressive.
return err
Expand Down

0 comments on commit 10b532f

Please sign in to comment.