Skip to content

Commit fc48280

Browse files
committed
json format for arrays
1 parent 070575d commit fc48280

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

NppJSONViewer/json.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,30 @@ json_format_string (const char *text)
10831083
pos++;
10841084
break;
10851085

1086+
case '[':
1087+
indentation++;
1088+
rcs_catcs (output, "{\n", 2);
1089+
for (i = 0; i < indentation; i++)
1090+
{
1091+
rcs_catc (output, '\t');
1092+
}
1093+
pos++;
1094+
break;
1095+
1096+
case ']':
1097+
indentation--;
1098+
rcs_catc (output, '\n');
1099+
// the for loop will compare i with potential negative values
1100+
// so we don't get caught in an infinite loop if the json is faulty with more "}" than "{"
1101+
// we just print out the same number of faulty "}" characters.
1102+
for (i = 0; i < indentation; i++)
1103+
{
1104+
rcs_catc (output, '\t');
1105+
}
1106+
rcs_catc (output, '}');
1107+
pos++;
1108+
break;
1109+
10861110
case ':':
10871111
rcs_catcs (output, ": ", 2);
10881112
pos++;

0 commit comments

Comments
 (0)