|
|
| version 1.1.2.5, 2017/11/28 11:45:05 | version 1.1.2.6, 2017/11/28 13:42:22 |
|---|---|
| Line 96 run_simple(json_t *json) | Line 96 run_simple(json_t *json) |
| return 0; | return 0; |
| } | } |
| static int | |
| dump(const char *jstr, jtok_t *toks, int toksnum, int indent) | |
| { | |
| register int i, j, k; | |
| if (!toksnum) | |
| return 0; | |
| if (toks->tok_type == J_VALUE) { | |
| printf("%.*s", (int) json_toklen(toks), json_tokstr(jstr, toks)); | |
| return 1; | |
| } else if (toks->tok_type == J_STRING) { | |
| printf("%.*s", (int) json_toklen(toks), json_tokstr(jstr, toks)); | |
| return 1; | |
| } else if (toks->tok_type == J_OBJECT) { | |
| printf("\n"); | |
| for (j = i = 0; i < json_toksize(toks); i++) { | |
| for (k = 0; k < indent; k++) | |
| printf(" "); | |
| j += dump(jstr, toks + j + 1, toksnum - j, indent + 1); | |
| printf(": "); | |
| j += dump(jstr, toks + j + 1, toksnum - j, indent + 1); | |
| printf("\n"); | |
| } | |
| return j + 1; | |
| } else if (toks->tok_type == J_ARRAY) { | |
| printf("\n"); | |
| for (j = i = 0; i < json_toksize(toks); i++) { | |
| for (k = 0; k < indent - 1; k++) | |
| printf(" "); | |
| printf(" - "); | |
| j += dump(jstr, toks + j + 1, toksnum - j, indent + 1); | |
| printf("\n"); | |
| } | |
| return j + 1; | |
| } | |
| return 0; | |
| } | |
| int | int |
| run_dump(json_t *json) | run_dump(json_t *json) |
| { | { |