Skip to content

Commit

Permalink
Fix JSON and JSONTIME export with gprints or rules
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
odoucet authored and oetiker committed Nov 10, 2015
1 parent 9dac2aa commit 9572780
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/rrd_xport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,10 +1061,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);
Expand All @@ -1077,10 +1077,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);
Expand Down

0 comments on commit 9572780

Please sign in to comment.