Using Newtonsoft.Json to convert Json strings into objects in c#

Hits: 0

1. Use NuGet to install Newtonsoft.Json dependencies

2. Introduce the Newtonsoft.Json namespace

3. Use

*3.1. First define an entity class corresponding to json*

public class student
        public int id { get; set; }
        public string name { get; set; 

3.2. Transformation

static void Main(string[] args)

            string jsonStudent = "[{\"id\":152,\"name\":\"789\"},{\"id\":888,\"name\":\"789\"}]";
            List<student> list= JsonConvert.DeserializeObject<List<student>>(jsonStudent);


You may also like...

Leave a Reply

Your email address will not be published.