goodtimes922
@goodtimes922

Как получить данные из weather? icon и description с помощью SwiftyJSON?

ВотJSON, нужно получить из weather поля description и icon, все никак не получается.

func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
       
       let checkString = searchBar.text!.replacingOccurrences(of: " ", with: "%20")
       let url = URL(string: "http://api.openweathermap.org/data/2.5/weather?q=\(checkString),&appid=b9be245f75c83dbb63d7700aa9e6f98e")!
       
        do {
            
            let jsonResult = try Data(contentsOf: url)
            let json =   JSON(jsonResult)
        
            let city = json["name"].stringValue
          //  let temp = json["main"]["temp"].intValue
            let weather = json["weather"][0]["description"].stringValue 
}

тут в weather приходит пустое значение

Спасибо
  • Вопрос задан
  • 419 просмотров
Решения вопроса 1
goodtimes922
@goodtimes922 Автор вопроса
ответ ["weather"][0]["description].stringValue
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы