【QT】JSON对象转换为string

QJsonObject resultJsonData;
resultJsonData["detect_objects"] = detectObjects;

// 将 QJsonObject 转换为字符串
QJsonDocument doc(resultJsonData);
QString resultJsonString = QString::fromUtf8(doc.toJson(QJsonDocument::Compact));

// 赋值给结果 JSON 对象
jsonObj["resultJson"] = resultJsonString;
posted @ 2026-03-30 14:31  taohuaxiaochunfeng  阅读(2)  评论(0)    收藏  举报