From 9aeac747dbe8b4b947b5269dd4c4226917f55de0 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Mon, 28 Dec 2015 01:54:32 +0100 Subject: [PATCH] API: port /server/:server/statistics to json11 --- pdns/ws-api.cc | 23 +++++++---------------- pdns/ws-api.hh | 3 --- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/pdns/ws-api.cc b/pdns/ws-api.cc index a2e1695863..a816b86256 100644 --- a/pdns/ws-api.cc +++ b/pdns/ws-api.cc @@ -79,8 +79,6 @@ strcasestr(const char *s1, const char *s2) #endif // HAVE_STRCASESTR -using namespace rapidjson; - static Json getServerDetail() { return Json::object { { "type", "Server" }, @@ -184,21 +182,14 @@ void apiServerStatistics(HttpRequest* req, HttpResponse* resp) { map items; productServerStatisticsFetch(items); - Document doc; - doc.SetArray(); + Json::array doc; typedef map items_t; - for(const items_t::value_type& item : items) { - Value jitem; - jitem.SetObject(); - jitem.AddMember("type", "StatisticItem", doc.GetAllocator()); - - Value jname(item.first.c_str(), doc.GetAllocator()); - jitem.AddMember("name", jname, doc.GetAllocator()); - - Value jvalue(item.second.c_str(), doc.GetAllocator()); - jitem.AddMember("value", jvalue, doc.GetAllocator()); - - doc.PushBack(jitem, doc.GetAllocator()); + for(const items_t::value_type& item : items) { + doc.push_back(Json::object { + { "type", "StatisticItem" }, + { "name", item.first }, + { "value", item.second }, + }); } resp->setBody(doc); diff --git a/pdns/ws-api.hh b/pdns/ws-api.hh index fd0071976c..201cf07a8d 100644 --- a/pdns/ws-api.hh +++ b/pdns/ws-api.hh @@ -23,9 +23,6 @@ #define PDNS_WSAPI_HH #include -#include "rapidjson/document.h" -#include "rapidjson/stringbuffer.h" -#include "rapidjson/writer.h" #include "webserver.hh" void apiServer(HttpRequest* req, HttpResponse* resp); -- 2.47.2