The JSON class provides the ability to parse JSON on the client side. This is a static object that is always available and matches the interface of recent browser's native JSON object.

This class also extends the native JSON interface with functions to support date encoding and parsing both in browser standard ISO format (default) and Microsoft's custom date encoding format.

This class is not loaded if a browser that natively supports JSON is used as most modern browsers do. The interface to this JSON class matches native JSON classes.It is based on Douglas Crockford's JSON JavaScript code with a number of modifications to handle date formatting in ISO and Microsoft formats. The parse() method checks for invalid characters in the JSON string before parsing and disallows executable code.

var person = { Name: "Rick", Company: "West Wind", Entered: new Date() }; var json = JSON.stringify(person); //{"Name":"Rick","Company":"West Wind","Entered":""2009-01-03T18:10:00Z""} alert(json); var copied = JSON.parseWithDates(json); alert( copied.Entered + " - " + copied.Name);

Dates are formatted in ISO date format by default. You can use stringifyWcf() to force dates to be encoded in Microsoft's date format. You can use the .parseWithDate() function to retrieve date values as real dates.