Hi,
I have read the other posts on here regarding problems with Qt5 and QJsonDocument but I am having a problems with it and none of the posts seem to help. Its not loading any content form the fromJson static method. No errors are reported QParseError.
Here is the code I have:
QFile file;
file.setFileName("c:\\jsondata\\data.txt");
file.open(QIODevice::ReadOnly | QIODevice::Text);
QString val = QString::fromUtf8(file.readAll());
QJsonParseError parseErr;
QJsonDocument jsonDoc = QJsonDocument::fromJson(val.toUtf8(),&parseErr);
file.close();
QJsonObject jsonObject = jsonDoc.object();
QJsonArray jsonArray = jsonObject["server"].toArray();
But jsonDoc is always null.
Any ideas why that might be, Hope someone can help me and I havent done something really stupid.
Many Thanks
Dave
↧