Home » Microsoft » 70-483 » Which code should you insert at line 03?
You are creating a console application named Appl.
App1 retrieves data from the Internet by using JavaScript Object Notation (JSON).
You are developing the following code segment (line numbers are included for reference only):
You need to ensure that the code validates the JSON string.
Which code should you insert at line 03?
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Explanation/Reference:
JavaScriptSerializer().Deserialize
Converts the specified JSON string to an object of type T.
Example:
string json = File.ReadAllText(Environment.CurrentDirectory + @”JSON.txt”);
Company company = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize(
Reference: C# – serialize object to JSON format using JavaScriptSerializer
http://matijabozicevic.com/blog/csharp-net-development/csharp-serialize-object-to-json-format-using-javascriptserialization
From distant memories, JavaScriptSerializer is not the best way to treat JSON, especially if you connect to another system that uses Java, PHP… The syntax used is slightly different than expected.
The Newtonsoft.JSON package is way better from this viewpoint.