If "alerts" might not exist, you need to wrap it in Option (see `options`
module in stdlib) like
WeatherForecast = ref object
latitude: float64
longitude: float64
timezone: string
currently: Currently
daily: Daily
alerts: Option[seq[Alerts]]
Runand then, after using json.to, check if it's present by `myobj.alerts.isSome()`, and if it is, get the value by `myobj.alerts.get()`
