minor style changes, add some comments - json2tsv - JSON to TSV converter | |
git clone git://git.codemadness.org/json2tsv | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit b3cce42c19a31a92b232d9e6a2bdb973169a7878 | |
parent bb2e9c03c80acfe0a339c43b8d622713b14b8ea5 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Wed, 23 Oct 2019 19:40:17 +0200 | |
minor style changes, add some comments | |
Diffstat: | |
M json.c | 15 +++++++++------ | |
1 file changed, 9 insertions(+), 6 deletions(-) | |
--- | |
diff --git a/json.c b/json.c | |
@@ -107,7 +107,8 @@ handlechr: | |
if (c == EOF) | |
break; | |
- if (c && strchr(" \t\n\r", c)) /* (no \v, \f, \b etc) */ | |
+ /* skip JSON white-space, (NOTE: no \v, \f, \b etc) */ | |
+ if (c && strchr(" \t\n\r", c)) | |
continue; | |
if (!c || !strchr(expect, c)) | |
@@ -197,6 +198,7 @@ escchr: | |
str[len++] = '\0'; | |
if (iskey) { | |
+ /* copy string as key, includi… | |
if (capacity(&(nodes[depth].na… | |
goto end; | |
memcpy(nodes[depth].name, str,… | |
@@ -221,13 +223,13 @@ escchr: | |
JSON_INVALID(); /* too deep */ | |
nodes[depth].index = 0; | |
- if (c == '{') { | |
+ if (c == '[') { | |
+ nodes[depth].type = TYPE_ARRAY; | |
+ expect = EXPECT_ARRAY_VALUE; | |
+ } else if (c == '{') { | |
iskey = 1; | |
nodes[depth].type = TYPE_OBJECT; | |
expect = EXPECT_OBJECT_STRING; | |
- } else if (c == '[') { | |
- nodes[depth].type = TYPE_ARRAY; | |
- expect = EXPECT_ARRAY_VALUE; | |
} | |
cb(nodes, depth + 1, ""); | |
@@ -268,7 +270,8 @@ escchr: | |
expect = EXPECT_END; | |
break; | |
case 'f': /* false */ | |
- if (GETNEXT() != 'a' || GETNEXT() != 'l' || GETNEXT() … | |
+ if (GETNEXT() != 'a' || GETNEXT() != 'l' || GETNEXT() … | |
+ GETNEXT() != 'e') | |
JSON_INVALID(); | |
nodes[depth].type = TYPE_BOOL; | |
cb(nodes, depth + 1, "false"); |