Parsing a JSON File from a File Picker and Populating the Items in a ListView (UWP App)

  1. Create a new UWP project in Visual Studio 2015,

    BLANK APP

  2. 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”.

    CODE

  3. 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

    CODE

  4. 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.

    NUGET

  5. Create a ListView in the MainPage.xaml to hold the list of items as below,

    CODE

  6. Create an asynchronous method in the MainPage.cs to read the JSON file, deserialize it and bind it to the ListView,

    CODE

  7. Call the method in the Main method as below,

    CODE

  8. Run the program, a file picker will open, select the file and the output will be as below.

    OUTPUT
Next Recommended Reading How To Create Calculator UWP App