I am using the following code for parsing:
QJson::Parser parser;
bool ok;
QVariantMap result=parser.parse (cityReply->readAll(),&ok).toMap();
if (!ok)
{
    qFatal("An error occurred during parsing");
    exit (1);
}
foreach (QVariant city, result.toList())
{
    QVariantMap names = city.toMap()开发者_Python百科;
    qDebug() << "\t-" << names["name"].toString();
}
My json String is [{"id":2,"name":"AAA"},{"id":1,"name":"BBB"}].
I got the following error:
'class QVariantMap' has no member named 'toList'.
is it possible to convert the QMap to QList?
result contain a serialized array as QVariant. You need to extract it before calling the toList() function. Since array is not named in Json string, you can access it by getting the first QVariant in the map and the doing what you have written in the question.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论