simplify type printing - 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 1232e02c50535bb4f9b363a2dada9525260ed059
(DIR) parent 92f3832c6fb144de7a13d962327128368912907b
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Mon, 14 Oct 2019 22:51:15 +0200
simplify type printing
Diffstat:
M json2tsv.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
---
(DIR) diff --git a/json2tsv.c b/json2tsv.c
@@ -14,11 +14,10 @@
#define GETNEXT getchar
enum JSONType {
- TYPE_UNKNOWN = 0,
- TYPE_PRIMITIVE,
- TYPE_STRING,
- TYPE_ARRAY,
- TYPE_OBJECT
+ TYPE_PRIMITIVE = 'p',
+ TYPE_STRING = 's',
+ TYPE_ARRAY = 'a',
+ TYPE_OBJECT = 'o'
};
#define JSON_MAX_NODE_DEPTH 32
@@ -315,13 +314,7 @@ processnode(struct json_node *nodes, size_t depth, const char *value)
}
putchar('\t');
- switch (nodes[depth - 1].type) {
- case TYPE_UNKNOWN: return;
- case TYPE_ARRAY: putchar('a'); break;
- case TYPE_OBJECT: putchar('o'); break;
- case TYPE_PRIMITIVE: putchar('p'); break;
- case TYPE_STRING: putchar('s'); break;
- }
+ putchar(nodes[depth - 1].type);
putchar('\t');
printvalue(value);
putchar('\n');