handle empty strings correctly - json2tsv - JSON to TSV converter
(HTM) git clone git://git.codemadness.org/json2tsv
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 794f0a187d7ed4d72e60fbad7186e17f71ca23c4
(DIR) parent 78d6bc291c601ffda102b3572c642bd79f415449
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Mon, 14 Oct 2019 23:08:23 +0200
handle empty strings correctly
reproduce: [""]
Diffstat:
M json2tsv.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
---
(DIR) diff --git a/json2tsv.c b/json2tsv.c
@@ -233,9 +233,7 @@ parsejson(void (*cb)(struct json_node *, size_t, const char *), const char **err
case ']':
case '}':
case ',':
- if (v &&
- (nodes[depth].type == TYPE_STRING ||
- nodes[depth].type == TYPE_PRIMITIVE)) {
+ if (v || nodes[depth].type == TYPE_STRING) {
value[v] = '\0';
cb(nodes, depth + 1, value);
v = 0;