小编aid*_*nMC的帖子

如何在qt中解码json

我想用qt解码以下json:

{
 "user": {
  "name": "string"
 }
}
Run Code Online (Sandbox Code Playgroud)

我试图用这个代码做,但不起作用:

QJsonDocument jsonResponse = QJsonDocument::fromJson(result.toUtf8());
QJsonObject jsonObject = jsonResponse.object();
QJsonArray jsonArray = jsonObject["user"].toArray();
foreach (const QJsonValue & value, jsonArray)
        {
            QJsonObject obj     = value.toObject();
            url          = obj["name"].toString();
        }
Run Code Online (Sandbox Code Playgroud)

c++ qt json qt5 qtcore

0
推荐指数
1
解决办法
972
查看次数

标签 统计

c++ ×1

json ×1

qt ×1

qt5 ×1

qtcore ×1