fix for empty key in objects - json2tsv - JSON to TSV converter | |
git clone git://git.codemadness.org/json2tsv | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 65cdb7d2d32ee17246328b50c5a0ae4deab585fb | |
parent 794f0a187d7ed4d72e60fbad7186e17f71ca23c4 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Tue, 15 Oct 2019 00:19:24 +0200 | |
fix for empty key in objects | |
reproduce: {"a":1,"":"b"} | |
Diffstat: | |
M json2tsv.c | 12 ++++++------ | |
1 file changed, 6 insertions(+), 6 deletions(-) | |
--- | |
diff --git a/json2tsv.c b/json2tsv.c | |
@@ -122,12 +122,11 @@ parsejson(void (*cb)(struct json_node *, size_t, const ch… | |
switch (c) { | |
case ':': | |
- nodes[depth].type = TYPE_PRIMITIVE; | |
- if (v) { | |
- if (!depth || nodes[depth - 1].type != TYPE_OB… | |
- *errstr = "object member, but not in a… | |
- goto end; | |
- } | |
+ if (!depth || nodes[depth - 1].type != TYPE_OBJECT) { | |
+ *errstr = "object member, but not in an object… | |
+ goto end; | |
+ } | |
+ if (v || nodes[depth].type == TYPE_STRING) { | |
value[v] = '\0'; | |
if (capacity(&(nodes[depth].name), &(nodes[dep… | |
goto end; | |
@@ -135,6 +134,7 @@ parsejson(void (*cb)(struct json_node *, size_t, const char… | |
nodes[depth].name[v] = '\0'; | |
v = 0; | |
} | |
+ nodes[depth].type = TYPE_PRIMITIVE; | |
break; | |
case '"': | |
v = 0; |