Skip to content

Commit

Permalink
Changed Json parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ubuntolog committed Dec 17, 2024
1 parent e71729b commit 9c175c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions src/GSvarServer/ServerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,22 +297,20 @@ HttpResponse ServerController::locateFileByType(const HttpRequest& request)

QJsonArray cached_array = cache_doc.array();
Log::error("cached_array.count() = " + QString::number(cached_array.count()));
for (int i=0; i<cached_array.count();++i)
for (const QJsonValue &value : cached_array)
{
Log::error(QString::number(i));
Log::error(cached_array.at(i).toObject()["filename"].toString());
if (cached_array.at(i).isObject())
if (value.isObject())
{
Log::error(QString::number(i) + " is object");
QJsonObject obj = value.toObject();
QJsonObject cached_object = cached_array.takeAt(i).toObject();
QString cached_filename = cached_object["filename"].toString();
QString cached_filename = obj.value["filename"].toString();
Log::error("cached_filename = " + cached_filename);

if (!cached_filename.isEmpty())
{
{
cached_object.insert("filename", createTempUrl(cached_filename, request.getUrlParams()["token"]));
updated_cached_array.append(cached_object);
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cppREST/ServerDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ QJsonDocument ServerDB::getFileLocation(const QString filename_with_path, const
Log::error("-----------");
Log::error(query.value(index_json_content).toString());
Log::error("-----------");
return QJsonDocument::fromJson(query.value(index_json_content).toString().toLocal8Bit());
return QJsonDocument::fromJson(query.value(index_json_content).toString().toUtf8());
}
return QJsonDocument();
}
Expand Down

0 comments on commit 9c175c4

Please sign in to comment.