The application includes the following code and recieves JSON data in the below format { "EmpId":1, "EmpName":"E1", "EmpSalary":2000.00 } public class Employee { public int EmpId{get;set;} public string EmpName{get;set;} public decimal EmpSalary {get ;set;} } public static Employee ConvertToEmployee(string json) { var serializer=new JavaScriptSerializer(); } we need to ensure that the ConvertToEmployee() method returns the JSON input string as an Employee object. What should be the return statement for the above method?
Back to QuestionsReturn serializer.ConvertToType<Employee>(json);
Return serializer.DeserializeObject(json);
Return serializer.Deserialize<Employee>(json);
Return (Employee)ser.Serialize(json);
JavaScriptSerializer.Deserialize<T> - Converts the specified JSON string to an object of type T
Answers Posted
PostedBy By: Abdul Samad Qureshi, at 02:46 PM on 27-March-2019
Answer Posted: C
Explanation: It should convert the json string into the type specified
Result: Correct