]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
API: port /server/:server/statistics to json11
authorChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Mon, 28 Dec 2015 00:54:32 +0000 (01:54 +0100)
committerChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Tue, 29 Dec 2015 22:29:16 +0000 (23:29 +0100)
pdns/ws-api.cc
pdns/ws-api.hh

index a2e169586396c470fa121da4dfeb0b92d5af09c4..a816b86256a53e571c801abc86369c7bf55d93dc 100644 (file)
@@ -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<string,string> items;
   productServerStatisticsFetch(items);
 
-  Document doc;
-  doc.SetArray();
+  Json::array doc;
   typedef map<string, string> 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);
index fd0071976c8d8b3efa42b34ad4a12a3c9a66f8a4..201cf07a8d9a489fcd1abd88afc952edf01be415 100644 (file)
@@ -23,9 +23,6 @@
 #define PDNS_WSAPI_HH
 
 #include <map>
-#include "rapidjson/document.h"
-#include "rapidjson/stringbuffer.h"
-#include "rapidjson/writer.h"
 #include "webserver.hh"
 
 void apiServer(HttpRequest* req, HttpResponse* resp);