f2b6a945eb6990470e8a4435b980fa22aa567b11 angie Fri Sep 11 13:28:00 2015 -0700 When a NULL tag ("var") was passed to jsonListStart, it wasn't printing the preceding comma if one was needed. To make NULL tag universally supported by everything that calls jsonWriteTag, change jsonWriteTag to always print the preceding comma if necessary, and print the tag only if non-NULL. diff --git src/inc/jsonWrite.h src/inc/jsonWrite.h index 7079f8b..4c0ce5d 100644 --- src/inc/jsonWrite.h +++ src/inc/jsonWrite.h @@ -18,31 +18,31 @@ /* Object to help output JSON */ { struct jsonWrite *next; struct dyString *dy; /* Most of this module is building json text in here */ bool objStack[128]; /* We need stack deep enough to handle nested objects and lists */ int stackIx; /* Current index in stack */ }; struct jsonWrite *jsonWriteNew(); /* Return new empty jsonWrite struct. */ void jsonWriteFree(struct jsonWrite **pJw); /* Free up a jsonWrite object. */ void jsonWriteTag(struct jsonWrite *jw, char *var); -/* Print out quoted tag followed by colon. Print out preceding comma if need be. */ +/* Print out preceding comma if necessary, and if var is non-NULL, quoted tag followed by colon. */ void jsonWriteEndLine(struct jsonWrite *jw); /* Write comma if in middle, and then newline regardless. */ void jsonWriteString(struct jsonWrite *jw, char *var, char *string); /* Print out "var": "val". If var is NULL, print val only. If string is NULL, "var": null . */ void jsonWriteDateFromUnix(struct jsonWrite *jw, char *var, long long unixTimeVal); /* Add "var": YYYY-MM-DDT-HH:MM:SSZ given a Unix time stamp. Var may be NULL. */ void jsonWriteNumber(struct jsonWrite *jw, char *var, long long val); /* print out "var": val as number. Var may be NULL. */ void jsonWriteDouble(struct jsonWrite *jw, char *var, double val); /* print out "var": val as number. Var may be NULL. */