mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-05-06 14:04:13 +00:00
API: fix #91
This commit is contained in:
parent
5fefaf07c4
commit
a76c9031c1
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue