parseObject() failed JSON

Hi

I cant parse data from openweather.com

Can someone please find the problem?

Thanks

Code:

void getWeather() 
{
  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  if (client2.connect(weatherserver, 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client2.print("GET /data/2.5/forecast?");
    client2.print("q=" + location);
    client2.print("&appid=" + apiKey);
    //client2.print("&cnt=3");
    client2.println("&units=metric");
    client2.println("Host: api.openweathermap.org");
    client2.println("Connection: close");
    client2.println();
  } else {
    Serial.println("unable to connect");
  }

  delay(1000);
  String line = "";
  while (client2.connected())
  {
    line = client2.readStringUntil('\n');
    Serial.println(line);
    //Serial.println(line);
    Serial.println("parsingValues");

    //create a json buffer where to store the json data
    StaticJsonBuffer<5000> jsonBuffer;

    JsonObject& root = jsonBuffer.parseObject(line);
    if (!root.success())
    {
      Serial.println("parseObject() failed");
      return;
    }

    //pridobi podatke iz json drevesa
    String nextWeatherTime01 = (const char*) root["list"][0]["dt_txt"];
    String nextWeather01 = (const char*) root["list"][0]["weather"][0]["main"];

    String nextWeatherTime11 =  (const char*) root["list"][1]["dt_txt"];
    String nextWeather11 =  (const char*) root["list"][1]["weather"][0]["main"];

    String nextWeatherTime21 = (const char*) root["list"][2]["dt_txt"];
    String nextWeather21 = (const char*) root["list"][2]["weather"][0]["main"];


    Serial.println("nextWeatherTime0");
    Serial.println(nextWeatherTime01);
    Serial.println("nextWeather0");
    Serial.println(nextWeather01);

    Serial.println("nextWeatherTime1");
    Serial.println(nextWeatherTime11);
    Serial.println("nextWeather1");
    Serial.println(nextWeather11);

    Serial.println("nextWeatherTime2");
    Serial.println(nextWeatherTime21);
    Serial.println("nextWeather2");
    Serial.println(nextWeather21);
  }
}

Respond:

Starting connection to server...
connected to server

parsingValues
parseObject() failed

Can someone please find the problem?

It's hiding in the code you didn't post.

StaticJsonBuffer<5000>

What device are you using that has room for 5000 bytes?

Problem solved. Not enough space...