© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
22 replies
SimplyKazuki

Can't read Json in WPF

I don't think I understand this error. It requires an array? but how? Should I make a loop?
        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;
        }
    }
        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;
        }
    }
unknown.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

WPF read and write to Json [Answered]
C#CC# / help
4y ago
❔ Can't build wpf project. "TestClassifier_w04izrw3_wpftmp.csproj" -- FAILED.
C#CC# / help
3y ago
✅ wpf json CRUD(mvvm)
C#CC# / help
2y ago
✅ WPF UI (lepoco/wpfui) Questions
C#CC# / help
2y ago