Posts

Showing posts with the label Json

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);                 }      ...

How to insert json data directly into table in sql.

Let us consider the below JSON as sample data, ex: [{ "info": [{ "id": 1, "name": "John", "surname": "Smith", "age": 25 }, { "id": 2, "name": "Abijal", "surname": "Smith", "age": 45 }, { "id": 3, "name": "Abhijit", "surname": "singh", "age": 41 }] }] To insert the above JSON we can use the below query, Query: declare @json varchar(max) =' [{ "info": [{ "id": 1, "name": "John", "surname": "Smith", "age": 25 }, { "id": 2, "name": "Abijal", "surname": "Smith", "age": 45 }, { "id": 3, "name": "Abhijit", "surname": "singh"...

How to get or extract the data from different json format in c#, webapi

                        JSON  C# Code  Model Class Sample 1: {    "EmployeeList": [       {          "EmpNumber": "10029597-3",          " JobCode ": "03363-001",          " Location ": "Triad North"       },       {          " EmpNumber ": "10029600-1",          " JobCode ": "03363-001",          " Location ": "Triad North"       },       {          " EmpNumber ": "10029626-2",     ...