Serialization
// Creating emp object
Employee Obj = new Employee ()
{
Name = "Hamid",
Designation= "Software Engineer"
};
// Convert Employee object to JOSN string format
string jsonDataTest = JsonConvert.SerializeObject(Obj);
Response.Write(jsonDataTest);
Deserialization
Employee obj= JsonConvert.DeserializeObject<Employee>(jsonDataTest );
Response.Write(obj.Name);
// Creating emp object
Employee Obj = new Employee ()
{
Name = "Hamid",
Designation= "Software Engineer"
};
// Convert Employee object to JOSN string format
string jsonDataTest = JsonConvert.SerializeObject(Obj);
Response.Write(jsonDataTest);
Deserialization
Employee obj= JsonConvert.DeserializeObject<Employee>(jsonDataTest );
Response.Write(obj.Name);
No comments:
Post a Comment