mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Fix to correctly deserialize JSON null value for Route.CPUs (#909)
This commit is contained in:
@@ -147,6 +147,12 @@ func (c MilliCPUs) String() string {
|
||||
func (c *MilliCPUs) UnmarshalJSON(data []byte) error {
|
||||
|
||||
outer := bytes.TrimSpace(data)
|
||||
|
||||
if bytes.Equal(outer, []byte("null")) {
|
||||
*c = MilliCPUs(0)
|
||||
return nil
|
||||
}
|
||||
|
||||
if !bytes.HasSuffix(outer, []byte("\"")) || !bytes.HasPrefix(outer, []byte("\"")) {
|
||||
return ErrInvalidJSON
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user