1
0

Make client and worldserver rest responses conform to json standard

This commit is contained in:
Emagi 2024-08-06 06:49:10 -04:00
parent ca28e77ae4
commit 0766ac4cf2
2 changed files with 8 additions and 4 deletions

View File

@ -52,11 +52,13 @@ void LWorldList::PopulateWorldList(http::response<http::string_body>& res) {
pt.put("world_name", world->GetName());
pt.put("status", (world->GetStatus() == 1) ? "online" : "offline");
pt.put("ip_addr", inet_ntoa(in));
maintree.add_child("WorldServer", pt);
maintree.push_back(std::make_pair("", pt));
}
}
boost::property_tree::write_json(oss, maintree);
boost::property_tree::ptree result;
result.add_child("WorldServers", maintree);
boost::property_tree::write_json(oss, result);
std::string json = oss.str();
res.body() = json;
res.prepare_payload();

View File

@ -71,12 +71,14 @@ void ZoneList::PopulateClientList(http::response<http::string_body>& res) {
pt.put("is_linkdead", linkdead);
pt.put("in_zone", cur->IsReadyForUpdates());
pt.put("zonename", (cur->GetPlayer() && cur->GetPlayer()->GetZone()) ? cur->GetPlayer()->GetZone()->GetZoneName() : "N/A");
maintree.add_child("Client", pt);
maintree.push_back(std::make_pair("", pt));
}
}
MClientList.unlock();
boost::property_tree::write_json(oss, maintree);
boost::property_tree::ptree result;
result.add_child("Clients", maintree);
boost::property_tree::write_json(oss, result);
std::string json = oss.str();
res.body() = json;
res.prepare_payload();