diff --git a/exttypes.go b/exttypes.go index 8e67fa5..86165f8 100644 --- a/exttypes.go +++ b/exttypes.go @@ -18,8 +18,12 @@ func (n JSONIPNet) MarshalJSON() ([]byte, error) { func (n *JSONIPNet) UnmarshalJSON(b []byte) error { cidr := strings.Trim(string(b), "\"") IP, IPNet, err := net.ParseCIDR(cidr) - IPNet.IP = IP - n.IPNet = *IPNet + + if err == nil { + IPNet.IP = IP + n.IPNet = *IPNet + } + return err }