Im trying to learn how to use JSON and Qt i have menaged and im having problem getting QJsonDocument from a file.The file opens correctly i can also see file's content with qDebug() but the QJsonDocument created from this file is always empty
if(stdButton==QDialogButtonBox::Ok) { qDebug()<<"accept button clicked"; QFile userList; userList.setFileName("users.json"); userList.open(QIODevice::ReadOnly); //using this qDebug i'm able to see files content qDebug()<<QJsonDocument::fromJson(userList.readAll()); //but this QJsonDocument is always empty QJsonDocument userDoc; userDoc=QJsonDocument::fromJson(userList.readAll()); if(userDoc.isEmpty()) { qDebug()<<"userDoc is empty"; } qDebug()<<userDoc; accept(); }