//if you want to use a list and add it to a file in json do this
using System.IO;
using System.Text.Json;
List<Data> data = new List<Data>();
public void SaveData()
{
using (StreamWriter sw = File.CreateText("data.json"))
{
sw.Write(JsonSerializer.Serialize(data));
}
}