Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Parsing a JSON File from a File Picker and Populating the Items in a ListView (UWP App)
WhatsApp
Rachhek Shrestha
8y
20.7
k
0
2
25
Blog
Create a new UWP project in Visual Studio 2015,
We have a JSON file in the Documents folder which contains list of 10 countries and their country codes as below. The keys here are “Country” and “Code”.
Create a class inside MainPage.cs with two strings properties as below. This class will provide the blueprint to hold the information from the JSON file
To read and parse information from the class we need to install a Nuget Package. Here we are installing Newtonsoft.JSON, a popular JSON framework from NUGET package manager.
Create a ListView in the MainPage.xaml to hold the list of items as below,
Create an asynchronous method in the MainPage.cs to read the JSON file, deserialize it and bind it to the ListView,
Call the method in the Main method as below,
Run the program, a file picker will open, select the file and the output will be as below.
Up Next
How To Create Calculator UWP App
Ebook Download
View all
Printing in C# Made Easy
Read by 22.3k people
Download Now!
Learn
View all
Membership not found