[SOLVED] JSON problem with Qt>=5.4
-
wrote on 4 Sept 2015, 07:15 last edited by stephane78 9 Apr 2015, 08:09
Hi,
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 ? -
wrote on 4 Sept 2015, 07:40 last edited by
Hi again,
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()); . -
wrote on 4 Sept 2015, 07:41 last edited byThis post is deleted!
-
wrote on 4 Sept 2015, 07:46 last edited by
Perhaps the method QJsonDocument::fromJson doesn't accept anymore the JSON that I receive....
-
wrote on 4 Sept 2015, 08:08 last edited by
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.
1/5