From 09435a8b155557873376148ddd08bbec887ec9b9 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 19 Sep 2021 17:33:40 -0700 Subject: Slight tweak to JSON output --- json.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/json.c b/json.c index e102cfe..86b7da5 100644 --- a/json.c +++ b/json.c @@ -36,11 +36,14 @@ static int _json_match(const char *text, match_t *m, int comma, bool verbose) default: printf("%c", *c); break; } } - printf("\",\"start\":%ld,\"end\":%ld,\"children\":[", - m->start - text, m->end - text); - for (int i = 0; m->children && m->children[i]; i++) - comma |= _json_match(text, m->children[i], comma, verbose); - printf("]}"); + printf("\",\"range\":[%ld,%ld]", m->start - text, m->end - text); + if (m->children) { + printf(",\"children\":["); + for (int i = 0; m->children && m->children[i]; i++) + comma |= _json_match(text, m->children[i], comma, verbose); + printf("]"); + } + printf("}"); return 1; } -- cgit v1.2.3