public void WriteVariablesToJSONFile_V2(string fileName, List<GingerParam> gingerParamsLst) { StringBuilder sbr = new StringBuilder(); int recNum = 0; sbr.Append("{"); foreach (GingerParam paramLine in gingerParamsLst) { if (recNum > 0) sbr.Append(", "); sbr.Append("\""); sbr.Append(paramLine.key); sbr.Append("\""); sbr.Append(":"); sbr.Append("\""); sbr.Append(paramLine.value); sbr.Append("\""); recNum++; } sbr.Append("}"); //open file stream using (StreamWriter file = File.CreateText(fileName)) { file.WriteLine(JSONHelper.FormatJSON(sbr.ToString())); } }