How can I read my JSON file in my program and load it into my list ?
This is what my "load" method looks like. My program can also load and display csv file therefore in my load method is also code from csv.
public void Load(string path)
{
Console.WriteLine("Dateiname eingeben, um zu laden.");
string filename = Console.ReadLine();
string json = ".json";
bool o = filename.Contains(json);
string fullFilePathName = System.IO.Path.Combine(path, filename);
string fContent = File.ReadAllText(fullFilePathName);
// Bremen;1200;1.2t\r\nHamburg;500;500kg\r\nBochum;5000;10kg
liste.Clear();
Console.WriteLine(fContent);
string[] datensaetze = fContent.Split("\r\n");
foreach (string datera in datensaetze)
{
if (datera.Length > 0)
{
// Format: Bremen;1200;1.2t
LKW lkw = new LKW();
if (lkw.Eingabe_CSV(datera) == true)
{
liste.Add(lkw);
}
else
{
}