Help with migration arduinojson 5 to 6

Hi.
I am using arduinojson library in esphome, in the latest versions they have switched from version 5 to 6 and my conde cannot compile anymore. According to upgrade tutorial i have do some changes and test test but i cant get it working :frowning: i am not expert of c++ this migration is hard for me.

Can you help me please?

This is the code previously working on arduinojson5:

         //Forecast
         if (id(forecast_5).has_state())
         {
          int wxx;
          int wyy;
          int forday = 1;
          
          const size_t capacity = JSON_ARRAY_SIZE(5) + 5*JSON_OBJECT_SIZE(5) + 560;
          DynamicJsonBuffer jsonBuffer(capacity);
          JsonArray& root = jsonBuffer.parseArray(id(forecast_5).state.c_str());
          //for (int i=0; i<root.size(); i++)
          for (int i=0; i <= 3; ++i)
          {
           if (i == 0) {wxx = wx;}
           if (i == 0) {wyy = wy;}
           if (i == 0) {forday = (id(esptime).now().day_of_week +1);}
           if (forday == 8)
           {
             forday = 1;
           }
           //Day 3-4 go down 
           //if (i == 2) {wyy += 38;}
           //if (i == 2) {wxx = 0;}
           JsonObject& root_0 = root[i];
           std::string root_0_condition = root_0["condition"]; // "sunny"
           float root_0_precipitation = root_0["precipitation"]; // 0.8
           float root_0_temperature = root_0["temperature"]; // 20.2
           float root_0_templow = root_0["templow"]; // 11.3
           //std::string root_0_datetime = root_0["datetime"]; // "2021-10-22T10:00:00+00:00"
           //int root_0_wind_bearing = root_0["wind_bearing"]; // 212
           //float root_0_wind_speed = root_0["wind_speed"]; // 9.4
           
           //Print to screen
           //Translated day
           it.printf(wxx, wyy, id(font_small), id(my_green), TextAlign::TOP_CENTER, "%s", dayDict_ext[forday]);
           //Icon condition
           it.printf(wxx, wyy +12, id(weather_font), TextAlign::TOP_CENTER, "%s", fonDict[root_0_condition.c_str()]);
           //Temp max
           it.printf(wxx, wyy+60, id(font_small_1), TextAlign::TOP_CENTER, "max %.0f°", root_0_temperature);
           //Temp min
           it.printf(wxx, wyy+70, id(font_small_1), TextAlign::TOP_CENTER, "min %.0f°", root_0_templow);
           //Rain in mm
           it.printf(wxx, wyy+80, id(font_small_1), TextAlign::TOP_CENTER, "%.0f mm", root_0_precipitation);
           //lines
           it.line(0, wy, it.get_width(), wy);
           it.line(0, wy+95, it.get_width(), wy+95);
           wxx += 85;
           forday += 1;
          }          
         }

It give me a series of webfont icon, and below temperature precipitation etc..

This is the test that i have done for migrating to 6:

         //Forecast
         if (id(forecast_5).has_state())
         {
          int wxx = 0;
          int wyy = 0;
          int forday = 1;
          
          StaticJsonDocument<768> root;
          deserializeJson(root, (id(forecast_5).state.c_str()));
          //for (int i=0; i <= 3; ++i)
          for (JsonObject item : root.as<JsonArray>())
          {
           if (item == 0) {wxx = wx;}
           if (item == 0) {wyy = wy;}
           if (item == 0) {forday = (id(esptime).now().day_of_week +1);}
           if (forday == 8)
           {
             forday = 1;
           }
           //Day 3-4 go down 
           //if (i == 2) {wyy += 38;}
           //if (i == 2) {wxx = 0;}
           JsonObject root_0 = root[item];
           std::string root_0_condition = root["condition"]; // "sunny"
           float root_0_precipitation = root["precipitation"]; // 0.8
           float root_0_temperature = root["temperature"]; // 20.2
           float root_0_templow = root["templow"]; // 11.3
           //std::string root_0_datetime = root["datetime"]; // "2021-10-22T10:00:00+00:00"
           //int root_0_wind_bearing = root["wind_bearing"]; // 212
           //float root_0_wind_speed = root["wind_speed"]; // 9.4
           
           //Print to screen
           //Translated day
           //it.printf(wxx, wyy, id(font_small), id(my_green), TextAlign::TOP_CENTER, "%s", dayDict_ext[forday]);
           //Icon condition
           //it.printf(wxx, wyy +12, id(weather_font), TextAlign::TOP_CENTER, "%s", fonDict[root_0_condition.c_str()]);
           //Temp max
           it.printf(wxx, wyy+60, id(font_small_1), TextAlign::TOP_CENTER, "max %.0f°", root_0_temperature);
           //Temp min
           it.printf(wxx, wyy+70, id(font_small_1), TextAlign::TOP_CENTER, "min %.0f°", root_0_templow);
           //Rain in mm
           it.printf(wxx, wyy+80, id(font_small_1), TextAlign::TOP_CENTER, "%.0f mm", root_0_precipitation);
           //lines
           it.line(0, wy, it.get_width(), wy);
           it.line(0, wy+95, it.get_width(), wy+95);
           wxx += 85;
           forday += 1;
          }          
         }

Now all the values report "0" sure there is something wrong that i dont'understand. I am not sure this is the right way.

Thank you in advice

With the help of my friend the correct working code for version 6 is:

         //Forecast
         if (id(forecast_5).has_state())
         {
          int wxx = 0;
          int wyy = 0;
          int forday = 1;
          DynamicJsonDocument doc(2048);
          deserializeJson(doc, (id(forecast_5).state.c_str()));
          JsonArray root = doc.as<JsonArray>();
          // for (int i=0; i<root.size(); i++)
          for (int i=0; i <= 3; ++i)
           {
           JsonObject root_0 = root[i];
           if (i == 0) {wxx = wx;}
           if (i == 0) {wyy = wy;}
           if (i == 0) {forday = (id(esptime).now().day_of_week +1);
           }
           if (forday == 8)
           {
             forday = 1;
           }
           //Day 3-4 go down 
           //if (i == 2) {wyy += 38;}
           //if (i == 2) {wxx = 0;}
           std::string root_0_condition = root_0["condition"]; // "sunny"
           float root_0_precipitation = root_0["precipitation"]; // 0.8
           float root_0_temperature = root_0["temperature"]; // 20.2
           float root_0_templow = root_0["templow"]; // 11.3
           //std::string root_0_datetime = root_0["datetime"]; // "2021-10-22T10:00:00+00:00"
           //int root_0_wind_bearing = root_0["wind_bearing"]; // 212
           //float root_0_wind_speed = root_0["wind_speed"]; // 9.4
           
           //Print to screen
           //Translated day
           it.printf(wxx, wyy, id(font_small), id(my_green), TextAlign::TOP_CENTER, "%s", dayDict_ext[forday]);
           //Icon condition
           it.printf(wxx, wyy +12, id(weather_font), TextAlign::TOP_CENTER, "%s", fonDict[root_0_condition.c_str()]);
           //Temp max
           it.printf(wxx, wyy+60, id(font_small_1), TextAlign::TOP_CENTER, "max %.0f°", root_0_temperature);
           //Temp min
           it.printf(wxx, wyy+70, id(font_small_1), TextAlign::TOP_CENTER, "min %.0f°", root_0_templow);
           //Rain in mm
           it.printf(wxx, wyy+80, id(font_small_1), TextAlign::TOP_CENTER, "%.0f mm", root_0_precipitation);
           //lines
           it.line(0, wy, it.get_width(), wy);
           it.line(0, wy+95, it.get_width(), wy+95);
           wxx += 85;
           forday += 1;
          }          
         }

I think is correct to post the result for sharing who need help whit this.
Thank you for all.