解析:
jsonObject
reply: {
"code": "9011",
"msg": null,
"success": false,
"result": null,
"tid": null,
"ext": {
"msg": "这是一行文字",
"certType": "1",
"code": "1001",
"showType": "1",
"traceData": "{ \"userType\":5, \"isLimited\":0, \"isOverFaceRecognitionNum\":0}",
"cert": "{\"topic\":\"实名认证\",\"showCancle\":true,\"buttonModelList\": [{\"scheme\":\"https://baidu#/\",\"schemeType\":\"NORMAL_PUSH\",\"type\":\"MAIN\",\"title\":\"去认证\"}],
\"content\":\"这是一串文字\"}"
}
}
QJsonObject extJson = reply["ext"].toObject();
QString cert= extJson["cert"].toString();
QJsonValue result = QJsonDocument::fromJson(cert.toUtf8()).object();
QString content = result["content"].toVariant().toString();
拼接:
{
"content":"{
"url":"yupaopao:\/\/plugin\/updateScheme? Id=dd99b13aebaf4330b95dce5a105f9136&name=invite",
"preside":"阿hui",
"icon":"https:\/\/tmp.cn\/image\/6b4a2d23-79f3-443c-a815-cc1a098e811e.png? image2\/format\/jpg\/thumbnail\/300x300\/format\/webp\/size-limit\/32k!"}",
}",
"ano":"najkc23mvklfsvml",
"type":123
}
上面是结果:
QJsonObject jsonValue;
jsonValue["ano"] = "ldakvnl678mlkva";
jsonValue["type"] = qwe;
QJsonObject content;
content["url"] = "name";
content["preside"] = "";
content["icon"] = "";
jsonValue["content"] = contentStr;