Introduction
Introduction Statistics Contact Development Disclaimer Help
simplify type printing - json2tsv - JSON to TSV converter
git clone git://git.codemadness.org/json2tsv
Log
Files
Refs
README
LICENSE
---
commit 1232e02c50535bb4f9b363a2dada9525260ed059
parent 92f3832c6fb144de7a13d962327128368912907b
Author: Hiltjo Posthuma <[email protected]>
Date: Mon, 14 Oct 2019 22:51:15 +0200
simplify type printing
Diffstat:
M json2tsv.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
---
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 c…
}
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');
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.