Skip to content

Commit 82877fb

Browse files
committed
fix: the string wasn't unmarshalled correctly and it contains the double quotes
1 parent a932856 commit 82877fb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

booltype.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
package cloudwatcher
22

3+
import (
4+
"encoding/json"
5+
)
6+
37
type Bool bool
48

59
func (bit *Bool) UnmarshalJSON(b []byte) error {
6-
txt := string(b)
10+
var txt string
11+
err := json.Unmarshal(b, &txt)
12+
if err != nil {
13+
return err
14+
}
715
*bit = Bool(txt == "1" || txt == "true")
816
return nil
917
}

0 commit comments

Comments
 (0)