⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)
[SOLVED] JSON problem with Qt>=5.4
stephane78 last edited by stephane78
This code is OK with Qt5.3.2 :
QString strReply = (QString)m_reponse->readAll(); QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8()); QJsonObject jsonObject = jsonResponse.object(); QJsonValue v = jsonObject["valuedouble"]; // or QJsonValue v = jsonObject.take("valuedouble"); double d=v.toDouble();
I get a value in the double d that is not 0.
but with Qt>= 5.4 this code doesn't runs not well, I get 0.0 in the double d although strReply is Ok.
Has someone an idea about this problem ?
I think there is a problem with the method QJsonDocument::fromJson, from Qt>=5.4. when debugging I have seen that a member variable from jsonResponse,d, is =0x0 in the case of Qt 5.4 and not in the case of Qt5.3.2,as a result to the call of QJsonDocument::fromJson(strReply.toUtf8()); .
This post is deleted!
Perhaps the method QJsonDocument::fromJson doesn't accept anymore the JSON that I receive....
Sorry, I have seen that strReply wasn't OK and it runs with QT5.3.2 but not with Qt5.4.there was a missing " at the end of the JSON.so my problem is solved.