stop overriding false txt

This commit is contained in:
davidnewhall2 2019-07-08 00:46:30 -07:00
parent 8002117b0a
commit d80ad93a17
1 changed files with 1 additions and 3 deletions

View File

@ -102,9 +102,7 @@ type FlexBool struct {
// UnmarshalJSON method converts armed/disarmed, yes/no, active/inactive or 0/1 to true/false. // UnmarshalJSON method converts armed/disarmed, yes/no, active/inactive or 0/1 to true/false.
// Really it converts ready, ok, up, t, armed, yes, active, enabled, 1, true to true. Anything else is false. // Really it converts ready, ok, up, t, armed, yes, active, enabled, 1, true to true. Anything else is false.
func (f *FlexBool) UnmarshalJSON(b []byte) error { func (f *FlexBool) UnmarshalJSON(b []byte) error {
if f.Txt = strings.Trim(string(b), `"`); f.Txt == "" { f.Txt = strings.Trim(string(b), `"`)
f.Txt = "false"
}
f.Val = f.Txt == "1" || strings.EqualFold(f.Txt, "true") || strings.EqualFold(f.Txt, "yes") || f.Val = f.Txt == "1" || strings.EqualFold(f.Txt, "true") || strings.EqualFold(f.Txt, "yes") ||
strings.EqualFold(f.Txt, "t") || strings.EqualFold(f.Txt, "armed") || strings.EqualFold(f.Txt, "active") || strings.EqualFold(f.Txt, "t") || strings.EqualFold(f.Txt, "armed") || strings.EqualFold(f.Txt, "active") ||
strings.EqualFold(f.Txt, "enabled") || strings.EqualFold(f.Txt, "ready") || strings.EqualFold(f.Txt, "up") || strings.EqualFold(f.Txt, "enabled") || strings.EqualFold(f.Txt, "ready") || strings.EqualFold(f.Txt, "up") ||