diff --git a/utils/json/option/bool.go b/utils/json/option/bool.go index 06784fa..42c8047 100644 --- a/utils/json/option/bool.go +++ b/utils/json/option/bool.go @@ -49,11 +49,11 @@ func (b *NullableBoolData) UnmarshalJSON(json []byte) (err error) { s := string(json) if s == "null" { - b.Init = false return } b.Val, err = strconv.ParseBool(s) + b.Init = true return } diff --git a/utils/json/option/custom.go b/utils/json/option/custom.go index d49ca6b..6850d17 100644 --- a/utils/json/option/custom.go +++ b/utils/json/option/custom.go @@ -58,13 +58,13 @@ func (i *NullableColorData) UnmarshalJSON(json []byte) error { s := string(json) if s == "null" { - i.Init = false return nil } v, err := strconv.ParseUint(s, 10, 32) i.Val = discord.Color(v) + i.Init = true return err } diff --git a/utils/json/option/number.go b/utils/json/option/number.go index 59b8746..039657c 100644 --- a/utils/json/option/number.go +++ b/utils/json/option/number.go @@ -56,13 +56,13 @@ func (u *NullableUintData) UnmarshalJSON(json []byte) error { s := string(json) if s == "null" { - u.Init = false return nil } v, err := strconv.ParseUint(s, 10, 64) u.Val = uint(v) + u.Init = true return err } @@ -99,13 +99,13 @@ func (i *NullableIntData) UnmarshalJSON(json []byte) error { s := string(json) if s == "null" { - i.Init = false return nil } v, err := strconv.ParseUint(s, 10, 64) i.Val = int(v) + i.Init = true return err } diff --git a/utils/json/option/string.go b/utils/json/option/string.go index 7c15343..cc71820 100644 --- a/utils/json/option/string.go +++ b/utils/json/option/string.go @@ -42,8 +42,9 @@ func (s NullableStringData) MarshalJSON() ([]byte, error) { func (s *NullableStringData) UnmarshalJSON(b []byte) error { if string(b) == "null" { - s.Init = false return nil } + + s.Init = true return json.Unmarshal(b, &s.Val) }