diff --git a/Json5/Json5Array.cs b/Json5/Json5Array.cs index bab4676..7835fb7 100644 --- a/Json5/Json5Array.cs +++ b/Json5/Json5Array.cs @@ -115,10 +115,24 @@ internal override string ToJson5String(string space, string indent) { string newLine = string.IsNullOrEmpty(space) ? "" : "\n"; + // TODO: Use string builder instead of string string s = "[" + newLine; + bool isFirstValue = true; + foreach (Json5Value value in this) - s += (value ?? Null).ToJson5String(space, indent + space) + "," + newLine; + { + if (isFirstValue) + { + isFirstValue = false; + } + else + { + s += "," + newLine; + } + + s += (value ?? Null).ToJson5String(space, indent + space); + } s += indent + "]";