void CommentDataManger::readJsonFile()
{
QJsonObject json;
QString strPath = QCoreApplication::applicationDirPath();
QDir dir(strPath);
dir.cd("config/");
QString _strPath = dir.absolutePath() + "/myFile.json";
QFile _file(_strPath);
if (_file.open(QIODevice::ReadWrite))
{
QByteArray _content = _file.readAll();
QJsonParseError error;
QJsonDocument _doc = QJsonDocument::fromJson(_content, &error);
if (!_doc.isEmpty())
{
json = _doc.object();
//...数据解析
}
_file.close();
}
}