We can parse a JSON file using JavaScriptSerializer class.

Before reading this article, I would recommend just go through once to my previous article because I am going to use model class and JSON file of the previous article:

Previously I had done the following:

  1. Person model class created

    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Web;  
    namespace CreatingJsonFile.Models  
    {  
        public class Person  
        {  
            public int PersonId  
            {  
                get;  
                set;  
            }  
            public string FirstName  
            {  
                get;  
                set;  
            }  
            public string LastName  
            {  
                get;  
                set;  
            }  
            public string City  
            {  
                get;  
                set;  
            }  
        }  
    }
  2. JSON File created

    [  
    {  
        "PersonId": 1,  
        "FirstName": "Ravi",  
        "LastName": "Patel",  
        "City": "Varanasi"  
    },  
    {  
        "PersonId": 2,  
        "FirstName": "Ranjeet",  
        "LastName": "Patel",  
        "City": "Delhi"  
    },  
    {  
        "PersonId": 3,  
        "FirstName": "Rajendra",  
        "LastName": "Patel",  
        "City": "Varanasi"  
    },  
    {  
        "PersonId": 4,  
        "FirstName": "Aarav",  
        "LastName": "Patel",  
        "City": "Bangalore"  
    }]

Now in this article we will use JavaScriptSerializer class to deserialize JSON from file.

Point of Interest

In this article we learned how to parse JSON file with C# and desrialization.