From 53bb99cf922b31fefe37225006d8e0c3f08da8fe Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Mon, 19 Nov 2012 13:18:34 +0000 Subject: [PATCH] fix up json escaping for domains git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2905 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/ws.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pdns/ws.cc b/pdns/ws.cc index 87b61a38b..9220e46bc 100644 --- a/pdns/ws.cc +++ b/pdns/ws.cc @@ -329,7 +329,10 @@ string StatWebServer::jsonstat(const map &varmap, void *ptr, bool UeberBackend B; SOAData sd; sd.db= (DNSBackend*)-1; - B.getSOA(ourvarmap["zone"], sd); + if(!B.getSOA(ourvarmap["zone"], sd) || !sd.db) { + cerr<<"Could not find domain '"<list(ourvarmap["zone"], sd.domain_id); DNSResourceRecord rr; @@ -359,18 +362,18 @@ string StatWebServer::jsonstat(const map &varmap, void *ptr, bool UeberBackend B; vector domains; B.getAllDomains(&domains); - ret += "{ domains: [ "; + ret += "{ \"domains\": [ "; bool first=true; BOOST_FOREACH(DomainInfo& di, domains) { if(!first) ret+=", "; first=false; - ret += "{ name: \""; - ret += di.zone +"\", kind: \""+ kinds[di.kind]+"\", masters: \""; + ret += "{ \"name\": \""; + ret += di.zone +"\", \"kind\": \""+ kinds[di.kind]+"\", \"masters\": \""; BOOST_FOREACH(const string& master, di.masters) { ret += master+ " "; } - ret+="\", serial: "+lexical_cast(di.serial)+", notified_serial: "+lexical_cast(di.notified_serial)+", last_check: "+lexical_cast(di.last_check); + ret+="\", \"serial\": "+lexical_cast(di.serial)+", \"notified_serial\": "+lexical_cast(di.notified_serial)+", \"last_check\": "+lexical_cast(di.last_check); ret+=" }"; } ret+= "]}"; -- 2.40.0