Posts

Showing posts with the label .Net Core

How to Read list of objects from json file and convert it into list of objects in c# .net core

  public List<CityMaster> getcities()         {             List<CityMaster> cities = new List<CityMaster>();             try             {                 var res = new List<CityMaster>();                 string path1 = $"{Directory.GetCurrentDirectory()}{@"\wwwroot\assets\citieslist.json"}";                 using (StreamReader r = new StreamReader(path1))                 {                     string json = r.ReadToEnd();                     res = JsonConvert.DeserializeObject<List<CityMaster>>(json);                 }      ...