QT

 QString str = "{\"translate\":[{\"translations\":[{\"text\":\"\u0645\u0631\u062d\u0628\u0627\"}],\"lang\":\"ar\"},{\"translations\":[{\"text\":\"\u0928\u092e\u0938\u094d\u0924\u0947\"}],\"lang\":\"hi\"}],\"datetime\":\"2012-12-01T01:12:17+08:00\"}";

 

int ipos4;

while (str.indexOf("\"text\":") != -1 && str.indexOf("\"lang\":") != -1)

{

         int ipos = str.indexOf("\"text\":");

         int ipos1 = str.indexOf("}],");

         QString strText = str.mid(ipos,((ipos1 - ipos -1)));

          strText.remove("\"text\":");

           strqDebug() << strText;

           Text.remove("\"");

            int ipos2 = str.indexOf("\"lang\":");

            int ipos3 = str.indexOf("}",ipos2);

            strText = str.mid(ipos2,((ipos3 - ipos2 -1)));        

            strText.remove("\"lang\":");

             strText.remove("\"");

             qDebug() << strText;

             ipos4 = str.indexOf(",{");

             if(ipos4 == -1)

             {

                  break;

             }

              else

             {

                    str = str.mid(ipos4+1);

             }

    }

 

 

 

 

 

 

          

你可能感兴趣的:(QT)