How to Read Countries, States, Cities data from Json file and Convert to List Objects in C#.

 Here I'm attaching the Json String of Countries List, States List, Cities List and also the scripts for all countries, states, cities.

You can just , use and convert the Json string to List Object and use them.

Models For Country, State, City:

public class CountryMaster
{
public int ID { get; set; }
public string CountryName { get; set; }
public string CountryCode { get; set; }
}
public class StateMaster
{
public int ID { get; set; }
public string StateName { get; set; }
public int CountryID { get; set; }
}
public class CityMaster
{
public int ID { get; set; }
public string CityName { get; set; }
public int StateID { get; set; }
}

Note: The above models are as per json 

 For Sample,

To get the country list you can use below code,

 var res = JsonConvert.DeserializeObject<List<CountryMaster>>("country json string"); 

Drive link:

drivelink    

Comments

Popular posts from this blog

Implement virtualisation in kendo drop down list using jquery ajax in mvc, aspx page

How to Create trigger to Update the NoofOrgs Count under each category in Category Table based on Temp Table in Sql Server

How to Preview the image and download which is in base64string format in mvc view using C#