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);
0 0 vote
Article Rating

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x