Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Commit 89aa592

Browse files
mcraihajordanbtucker
authored andcommitted
Remove unneeded spaces and commas from Json5Object.ToJson5String
This fixes at least following tests: UnquotedPropertyNamesTest EmptyStringPropertyNamesTest SpecialCharacterPropertyNamesTest UnicodePropertyNamesTest MultiplePropertiesTest NestedObjectsTest
1 parent f5f5abb commit 89aa592

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Json5/Json5Object.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,24 @@ internal override string ToJson5String(string space, string indent)
6969
{
7070
string newLine = string.IsNullOrEmpty(space) ? "" : "\n";
7171

72+
// TODO: Use string builder instead of string
7273
string s = "{" + newLine;
7374

75+
bool isFirstValue = true;
76+
7477
foreach (var property in this)
7578
{
76-
s += indent + space + KeyToString(property.Key) + ": ";
77-
s += (property.Value ?? Null).ToJson5String(space, indent + space) + "," + newLine;
79+
if (isFirstValue)
80+
{
81+
isFirstValue = false;
82+
}
83+
else
84+
{
85+
s += "," + newLine;
86+
}
87+
88+
s += indent + space + KeyToString(property.Key) + ":";
89+
s += (property.Value ?? Null).ToJson5String(space, indent + space);
7890
}
7991

8092
s += indent + "}";

0 commit comments

Comments
 (0)