.Net

NewtonSoft JSON Serialize And Deserialize in C#

Here we will learn how to use NewtonSoft JSON to serialize and deserialize in Asp.Net using c# with example or Use newtonsoft.json for JSON serialization and deserialization in asp.net using c#.

JSON Serialization Method
Following is the serialize method to serialize list items into JSON string format.

List<Students> details = new List<Students>();
Students student= new Students();
details.Add(new Students { userid = 1, username = "Suman", location = "Punjab" });
string Serialize= JsonConvert.SerializeObject(details);

JSON DeSerialization Method

Following is the serialize method to serialize list items into JSON string format.

string Details= "[{\"userid\":1,\"username\":\"Suman\",\"location\":\"Punjab\"},{\"userid\":2,\"username\":\"Roshni\",\"location\":\"Kolkata\"}]";
var user = JsonConvert.DeserializeObject<List<Students>>(Details);

Shaiv Roy

Hy Myself shaiv roy, I am a passionate blogger and love to share ideas among people, I am having good experience with laravel, vue js, react, flutter and doing website and app development work from last 7 years.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button