Fix admin/spiderdb json output

This commit is contained in:
Ai Lin Chia
2018-01-11 12:08:36 +01:00
parent 2fd2d52877
commit 5651bcc22f
2 changed files with 15 additions and 4 deletions

@ -519,6 +519,13 @@ static bool generatePageJSON(CollectionRec *cr, SafeBuf *sb, const SafeBuf *dole
j++;
}
if (j > 0) {
sb->removeLastChar('\n');
sb->removeLastChar(',');
sb->removeLastChar('\t');
sb->removeLastChar('\t');
}
// end the table
sb->safePrintf("\t]\n");
@ -549,6 +556,13 @@ static bool generatePageJSON(CollectionRec *cr, SafeBuf *sb, const SafeBuf *dole
return false;
}
if (doledbbuf->length() > 0) {
sb->removeLastChar('\n');
sb->removeLastChar(',');
sb->removeLastChar('\t');
sb->removeLastChar('\t');
}
sb->safePrintf("\t],\n");
/////////////////

@ -228,10 +228,6 @@ int32_t SpiderReply::print(SafeBuf *sbarg) const {
* }
*/
int32_t SpiderRequest::printToJSON(SafeBuf *sb, const char *status, const XmlDoc *xd, int32_t row) const {
if (row != 0) {
sb->safePrintf("\t\t,\n");
}
sb->safePrintf("\t\t{\n");
int64_t elapsedMS = 0;
@ -268,6 +264,7 @@ int32_t SpiderRequest::printToJSON(SafeBuf *sb, const char *status, const XmlDoc
// if ( m_hasAuthorityInlink ) sb->safePrintf("HASAUTHORITYINLINK ");
sb->safePrintf("\t\t}\n");
sb->safePrintf("\t\t,\n");
return sb->length();
}