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 Questions

Return serializer.ConvertToType<Employee>(json);


Return serializer.DeserializeObject(json);


Return serializer.Deserialize<Employee>(json);


Return (Employee)ser.Serialize(json);


Author Explanation :

 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

Back to Questions

© Copyright 1997 - 2019 | | | All Rights Reserved.
Bestdotnet google plus
Enquiry Now