WPF read and write to Json [Answered]

The title says it all, I don't know how to read and write to Json properly. I tried some things but they don't seem to work
        static List<persondata> persondata()
        {
            string fileName = @"C:\Users\elko\source\repos\JsonData\JsonData\bin\Debug\net6.0-windows\Persons.json";
            if (File.Exists(fileName))
            {
                var persons = JsonConvert.DeserializeObject<List<persondata>>
                    (File.ReadAllText(fileName));

                return persons;
            }
            return null;
        }
    }

i have looked for tutorials guides everywhere, but nothing worked for me. I must be doing something wrong
Was this page helpful?