PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 10?

An application receives JSON data in the following format:
{ “FirstName” : “David”,
“LastName” : “Jones”,
“Values” : [0, 1, 2] }
The application includes the following code segment. (Line numbers are included for reference only.)
01 public class Name
02 {
03 public int[] Values { get; set; }
04 public string FirstName { get; set; }
05 public string LastName { get; set; }
06 }
07 public static Name ConvertToName(string json)
08 {
09 var ser = new JavaScriptSerializer();
10
11 }
You need to ensure that the ConvertToName() method returns the JSON input string as a Name object.
Which code segment should you insert at line 10?

PrepAway - Latest Free Exam Questions & Answers

A.
return ser.ConvertToType<Name>(json);

B.
return ser.DeserializeObject(json);

C.
return ser.Deserialize<Name>(json) ;

D.
return (Name)ser.Serialize(json);

Explanation:
JavaScriptSerializer.Deserialize<T> – Converts the specified JSON string to an object of type T.
http://msdn.microsoft.com/en-us/library/bb355316.aspx


Leave a Reply