I developed this simple Windows application that might help you to visualize the data better. The code uses the System.Web.Extenions.dll. If you want to use it in a Windows Forms application, be sure to change the target framework from .Net Framework 4 Client Profile to .Net Framework 4 otherwise you wont be able to add the reference. Once you add the reference you'll have access to the System.Web.Script.Serialization namespace. Within this namespace is a class called JavaScriptSerializer. It has a Deserialize method which can be used to deserialize JSON data to a Type. Use can see from the example code how easy it is to deserialize JSON data with this class.
- JavaScriptSerializer js = new JavaScriptSerializer();
- try
- {
- string strData = "JSON data";
- Dictionary<string, object> dic = js.Deserialize<Dictionary<string, object>>(strData);
- }
- catch (ArgumentException argE)
- {
- MessageBox.Show("JSON data is not valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
Download
No comments:
Post a Comment