Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void json_printTree(FILE* fp, struct json_node *n)
- {
- const int JSON_INDENT = 4;
- static int indent = 0;
- struct json_node *tmp;
- assert(n);
- if (n->key && !strcmp(n->key, "enabled")) {
- fprintf(fp, "%*s", indent*JSON_INDENT, "");
- fprintf(fp, "\x1b[35mTYPE IS: %d, VALUE IS: %d\x1b[0m\n", n->type, n->int_val);
- }
- fprintf(fp, "%*s", indent*JSON_INDENT, "");
- if (n->key)
- fprintf(fp, "\"%s\": ", n->key);
- int print_children = 0;
- char brackets[2];
- switch(n->type) {
- case JSON_NULL: fprintf(fp, "null");
- break;
- case JSON_BOOL:
- if (n->int_val)
- fprintf(fp, "true");
- else
- fprintf(fp, "false");
- break;
- case JSON_INT: fprintf(fp, "%d", n->int_val); break;
- case JSON_FLOAT: fprintf(fp, "%f", n->float_val); break;
- case JSON_STRING: fprintf(fp, "\"%s\"", n->str_val?n->str_val:""); break;
Add Comment
Please, Sign In to add comment