Make client and worldserver rest responses conform to json standard
This commit is contained in:
parent
ca28e77ae4
commit
0766ac4cf2
@ -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();
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user