fix: modify boiii.json parser

This commit is contained in:
Diavolo 2023-12-02 22:36:49 +01:00
parent 613d5744f7
commit 5f8c9e540f
2 changed files with 10 additions and 8 deletions

View File

@ -64,6 +64,8 @@
#undef min #undef min
#endif #endif
#undef GetObject
#include <cassert> #include <cassert>
#include <cctype> #include <cctype>
#include <climits> #include <climits>

View File

@ -34,9 +34,9 @@ namespace updater
std::vector<file_info> parse_file_infos(const std::string& json) std::vector<file_info> parse_file_infos(const std::string& json)
{ {
rapidjson::Document doc{}; rapidjson::Document doc{};
doc.Parse(json.data(), json.size()); const rapidjson::ParseResult result = doc.Parse(json.data(), json.size());
if (!doc.IsArray()) if (!result || !doc.IsArray())
{ {
return {}; return {};
} }
@ -45,19 +45,19 @@ namespace updater
for (const auto& element : doc.GetArray()) for (const auto& element : doc.GetArray())
{ {
if (!element.IsArray()) if (!element.IsObject())
{ {
continue; continue;
} }
auto array = element.GetArray(); auto file = element.GetObject();
file_info info{}; file_info info{};
info.name.assign(array[0].GetString(), array[0].GetStringLength()); info.name = file["name"].GetString();
info.size = array[1].GetInt64(); info.size = file["size"].GetUint64();
info.hash.assign(array[2].GetString(), array[2].GetStringLength()); info.hash = file["hash"].GetString();
files.emplace_back(std::move(info)); files.emplace_back(info);
} }
return files; return files;