Skip to content

Commit 06ffc61

Browse files
committed
Bug fix: 压缩形式输出至控制台时高亮错误
1 parent e438027 commit 06ffc61

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

core/utils/outputer.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,7 @@ void printString(const struct JsonString* str, const int color) {
5959
fputc('"', f);
6060
char * reader = str->str;
6161
while (*reader) {
62-
if (*reader == '\n') fputs("\\n", f);
63-
else if (*reader == '\t') fputs("\\t", f);
64-
else if (*reader == '\r') fputs("\\r", f);
65-
else if (*reader == '"') fputs("\\\"", f);
66-
else if (*reader == '\'') fputs("\\'", f);
67-
else fputc(*reader, f);
68-
62+
fputc(*reader, f);
6963
reader++;
7064
}
7165
fputc('"', f);if(color) fputs(ANSI_COLOR_RESET, f);
@@ -121,17 +115,16 @@ void printNONE(const int color) {
121115
}
122116

123117
void printObject(const struct JsonObj* obj, const int color){
124-
fputc('{', f);
118+
fputs("{", f);
125119
for (int i = 0; i < obj->size; i++) {
126120
if(color) {
127121
fputs(ANSI_COLOR_MAGENTA, f);
128-
printString(obj->key + i, color);
122+
printString(obj->key + i, 0);
129123
fputs(ANSI_COLOR_RESET, f);
130-
}else printString(obj->key + i, color);
131-
putc(':', f);
132-
printJsonVal(obj->value + i, color);
133-
if (i != obj->size - 1) fputc(',', f);
134-
} fputc('}', f);
124+
}else printString(obj->key + i, 0);
125+
fputs(": ", f); printJsonVal(obj->value + i, color);
126+
if (i != obj->size - 1) fputs(",", f);
127+
}fputs("}", f);
135128
}
136129
void printArray(const struct JsonArray* array, const int color){
137130
fputc('[', f);

0 commit comments

Comments
 (0)