From 9857fdbca9c1d339b266df3e6e29444bbb188192 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Mon, 28 Dec 2015 01:54:27 +0100 Subject: [PATCH] API: port /server/:server/config to json11 --- pdns/ws-api.cc | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/pdns/ws-api.cc b/pdns/ws-api.cc index 780878a4a..a2e169586 100644 --- a/pdns/ws-api.cc +++ b/pdns/ws-api.cc @@ -114,25 +114,18 @@ void apiServerConfig(HttpRequest* req, HttpResponse* resp) { vector items = ::arg().list(); string value; - Document doc; - doc.SetArray(); - for(const string& item : items) { - Value jitem; - jitem.SetObject(); - jitem.AddMember("type", "ConfigSetting", doc.GetAllocator()); - - Value jname(item.c_str(), doc.GetAllocator()); - jitem.AddMember("name", jname, doc.GetAllocator()); - + Json::array doc; + for(const string& item : items) { if(item.find("password") != string::npos) value = "***"; else value = ::arg()[item]; - Value jvalue(value.c_str(), doc.GetAllocator()); - jitem.AddMember("value", jvalue, doc.GetAllocator()); - - doc.PushBack(jitem, doc.GetAllocator()); + doc.push_back(Json::object { + { "type", "ConfigSetting" }, + { "name", item }, + { "value", value }, + }); } resp->setBody(doc); } -- 2.40.0