diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2022-06-12 11:24:09 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2022-06-12 11:24:09 -0400 |
commit | 688289f1abb3fea7ee85cefccd9248fb9de0fe5c (patch) | |
tree | df09499eb76dce54507a62b983e26df2e40adcf3 /jdtalk.h | |
parent | 5010d17025ffbaa7f9f8b5fe9169b574040d2773 (diff) | |
download | jdtalkc-688289f1abb3fea7ee85cefccd9248fb9de0fe5c.tar.gz |
Implement output as JSON
Diffstat (limited to 'jdtalk.h')
-rw-r--r-- | jdtalk.h | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -24,6 +24,15 @@ #define WT_ADVERB 3 #define WT_VERB 4 +#define JSON_BEGIN(FP) fprintf(FP, "{\n"); +#define JSON_INDENT(FP, LEVEL) for (size_t indenter = 0; indenter < LEVEL; indenter++) { fprintf(FP, " "); } +#define JSON_NEXT_ITEM(FP) fprintf(FP, ",\n"); +#define JSON_NEXT_LINE(FP) fprintf(FP, "\n"); +#define JSON_LIST_BEGIN(FP, KEY) JSON_INDENT(FP, 1); fprintf(FP, "\"%s\": [", KEY); +#define JSON_LIST_APPEND(FP, VALUE) JSON_INDENT(FP, 2); fprintf(FP, "\"%s\"", VALUE); +#define JSON_LIST_END(FP) fprintf(FP, "]\n"); +#define JSON_END(FP) fprintf(FP, "}\n"); + struct Word { char *word; unsigned type; |