How to convert a QJsonObject to a QString
-
wrote on 27 Jan 2015, 23:18 last edited by
I have a QJsonObject data and want to convert to QString. How can I do this? Searched for help in Qt, it only can convert QJsonObject to QVariantMap...
Thanks in advance.
-
wrote on 28 Jan 2015, 00:03 last edited by
You need to get a QJsonValue, which has a .toString() method. That or you need to use QJsonDocument to turn a whole object into a string.
@QString jsonToString(QJsonObject json)
{QJsonDocument Doc(json); QByteArray ba = Doc.toJson(); return QString(ba);
}@
-
wrote on 28 Jan 2015, 07:51 last edited by
Indeed. Go through QJsonDocument.
-
wrote on 28 Jan 2015, 15:28 last edited by
Thank you, I will try that.
1/4