Skip to content

Commit

Permalink
Bug fix: 压缩形式输出至控制台时高亮错误
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined-ux committed Dec 12, 2023
1 parent e438027 commit 06ffc61
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions core/utils/outputer.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,7 @@ void printString(const struct JsonString* str, const int color) {
fputc('"', f);
char * reader = str->str;
while (*reader) {
if (*reader == '\n') fputs("\\n", f);
else if (*reader == '\t') fputs("\\t", f);
else if (*reader == '\r') fputs("\\r", f);
else if (*reader == '"') fputs("\\\"", f);
else if (*reader == '\'') fputs("\\'", f);
else fputc(*reader, f);

fputc(*reader, f);
reader++;
}
fputc('"', f);if(color) fputs(ANSI_COLOR_RESET, f);
Expand Down Expand Up @@ -121,17 +115,16 @@ void printNONE(const int color) {
}

void printObject(const struct JsonObj* obj, const int color){
fputc('{', f);
fputs("{", f);
for (int i = 0; i < obj->size; i++) {
if(color) {
fputs(ANSI_COLOR_MAGENTA, f);
printString(obj->key + i, color);
printString(obj->key + i, 0);
fputs(ANSI_COLOR_RESET, f);
}else printString(obj->key + i, color);
putc(':', f);
printJsonVal(obj->value + i, color);
if (i != obj->size - 1) fputc(',', f);
} fputc('}', f);
}else printString(obj->key + i, 0);
fputs(": ", f); printJsonVal(obj->value + i, color);
if (i != obj->size - 1) fputs(",", f);
}fputs("}", f);
}
void printArray(const struct JsonArray* array, const int color){
fputc('[', f);
Expand Down

0 comments on commit 06ffc61

Please sign in to comment.