This commit is contained in:
mavolin 2020-05-22 19:51:15 +02:00 committed by diamondburned
parent 5fefaf07c4
commit a76c9031c1
4 changed files with 6 additions and 5 deletions

View File

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

View File

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

View File

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

View File

@ -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)
}