From be80cab93763f9608e7e6b425ec32097667a6fb3 Mon Sep 17 00:00:00 2001 From: Olivier Doucet Date: Fri, 6 Nov 2015 19:50:07 +0100 Subject: [PATCH] Fix JSON and JSONTIME export with gprints or rules When you have gprints or rules, json is not formated correctly : a comma is inserted after each block, making two mistakes : - there is no comma between "legend" and "gprints" block - there is a trailing comma in "meta" block I decided to rewrite this part and add the comma before each block, so this works in all cases : when you don't have any block, only one of them or both. --- src/rrd_xport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rrd_xport.c b/src/rrd_xport.c index 629b118e..971a7b5a 100644 --- a/src/rrd_xport.c +++ b/src/rrd_xport.c @@ -1067,10 +1067,10 @@ int rrd_xport_format_addprints(int flags,stringbuffer_t *buffer,image_desc_t *im /* now add gprints */ if (gprints.len) { if (json){ - snprintf(buf,sizeof(buf)," \"%s\": [\n","gprints"); + snprintf(buf,sizeof(buf)," ,\"%s\": [\n","gprints"); addToBuffer(buffer,buf,0); addToBuffer(buffer,(char*)gprints.data+2,gprints.len-2); - addToBuffer(buffer,"\n ],\n",0); + addToBuffer(buffer,"\n ]\n",0); } else { snprintf(buf,sizeof(buf)," <%s>\n", "gprints"); addToBuffer(buffer,buf,0); @@ -1083,10 +1083,10 @@ int rrd_xport_format_addprints(int flags,stringbuffer_t *buffer,image_desc_t *im /* now add rules */ if (rules.len) { if (json){ - snprintf(buf,sizeof(buf)," \"%s\": [\n","rules"); + snprintf(buf,sizeof(buf)," ,\"%s\": [\n","rules"); addToBuffer(buffer,buf,0); addToBuffer(buffer,(char*)rules.data+2,rules.len-2); - addToBuffer(buffer,"\n ],\n",0); + addToBuffer(buffer,"\n ]\n",0); } else { snprintf(buf,sizeof(buf)," <%s>\n", "rules"); addToBuffer(buffer,buf,0); -- 2.47.2