3e958f680f3aa81d2571fe0be872ba5439ef839f kent Wed Aug 5 09:02:54 2015 -0700 Improving opening module level comment. diff --git src/inc/jsonWrite.h src/inc/jsonWrite.h index 8f12bf2..40b125c 100644 --- src/inc/jsonWrite.h +++ src/inc/jsonWrite.h @@ -1,16 +1,27 @@ -/* jsonWrite - Helper routines for writing out JSON. */ +/* jsonWrite - Helper routines for writing out JSON. The idea of this is you build up a string inside + * of the jsonWrite object using various jsonWrite methods, and then output the string where you want. + * + * struct jsonWrite *jw = jsonWriteNew(); + * jsonWriteObjectStart(jw, NULL); // Anonymous outer object + * jsonWriteStringf(jw, "user", "%s %s", user->firstName, user->lastName); + * jsonWriteNumber(jw, "year", 2015); + * jsonWriteObjectEnd(jw); + * printf("%s\n", jw->dy->string); + * jsonWriteFree(&jw); + */ + #ifndef JSONWRITE_H #define JSONWRITE_H struct jsonWrite /* 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. */