I am putting data into a json file with Jsonserializer with the indent option turned on, but the arrays I'm storing aren't formatted to my liking.
[
{
"filePath": "C:\\Users\\Audio\\2.mp3",
"playAddress": 0,
"loop": false,
"SpeakerVolumes": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
this is a snippet of what part of the json file looks like.
void saveCfg()
{
Console.WriteLine(firstSave);
if (firstSave == true)
{
firstSave = false;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "config files (*.json)|*.json|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
writeFilePath = saveFileDialog1.FileName;
}
}
List<AudioDataFormat> audioData = new List<AudioDataFormat>();
//Console.WriteLine()
for (int i = 0; i < audioFilePaths.Count; i++)
{
audioData.Add(new AudioDataFormat()
{
filePath = audioFilePaths[i],
playAddress = playAddress[i],
loop = loop[i],
SpeakerVolumes = speakerVolumes[i],
fades = fades[i],
fadeAddress = fadeAddress[i],
fadeVol = fadeVol[i],
fadeTime = fadeTime[i],
});
}
var options = new JsonSerializerOptions { WriteIndented = true };
string json = JsonSerializer.Serialize(audioData.ToArray(), options);
File.WriteAllText(writeFilePath, json);
}
this is how i save the data in the json file.
I would like the entire array to be in one line. Is this possible?
Kind regards Guus