src/main.cpp
/**************************************************************************************************************************/
// parse the JSON response from the WEATHER API
/**************************************************************************************************************************/
parse the JSON response from the WEATHER API
parse the JSON response from the WEATHER API
void parseWeatherJson( String json ) {
  DynamicJsonDocument doc(1024);
  DeserializationError error = deserializeJson(doc, json);
  if (error){
    Serial.println(error.c_str());
  }
  float localTemp = doc["main"]["temp"];
  myWeatherData.temperature = (1.8 * (localTemp - 273.15)) + 32;
  myWeatherData.humidity = doc["main"]["humidity"];
  myWeatherData.condition = (const char*)doc["weather"][0]["main"];
  myWeatherData.conditionDetailed = (const char*)doc["weather"][0]["description"];
}
void parseWeatherJson ( String json ) { DynamicJsonDocument doc ( 1024 ) ; DeserializationError error = deserializeJson ( doc , json ) ; if ( error ) { Serial . println ( error . c_str ( ) ) ; } float localTemp = doc [ " " ] [ " " ] ; myWeatherData . temperature = ( 1.8 * ( localTemp - 273.15 ) ) + 32 ; myWeatherData . humidity = doc [ " " ] [ " " ] ; myWeatherData . condition = ( const char * ) doc [ " " ] [ 0 ] [ " " ] ; myWeatherData . conditionDetailed = ( const char * ) doc [ " " ] [ 0 ] [ " " ] ; }
parse the JSON response from the WEATHER API
parse the JSON response from the WEATHER API