Provides serialization and deserialization functionality for AJAX-enabled applications.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
Thetype exposes the following members.
|ConvertToType(Object, Type)||Converts the specified object to the specified type.|
|ConvertToType(T)(Object)||Converts the given object to the specified type.|
|Deserialize(String, Type)||Converts a JSON-formatted string to an object of the specified type.|
|Deserialize(T)(String)||Converts the specified JSON string to an object of type T.|
|DeserializeObject||Converts the specified JSON string to an object graph.|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|RegisterConverters||Registers a custom converter with the instance.|
|Serialize(Object)||Converts an object to a JSON string.|
|Serialize(Object, StringBuilder)||Serializes an object and writes the resulting JSON string to the specified StringBuilder object.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
Mapping Between Managed Types and JSON
The following table shows the mapping between managed types and JSON for the serialization process. These managed types are natively supported by . When you are deserializing from a JSON string to a managed type, the same mapping applies. However, deserialization can be asymmetric; not all serializable managed types can be deserialized from JSON.
A multidimensional array is serialized as a one-dimensional array, and you should use it as a flat array.
String (UTF-8 encoding only).
Single null char (such as, \0 )
Boolean. Represented in JSON as true or false
a null reference (Nothing in Visual Basic) (a null reference (Nothing in Visual Basic) object references and Nullable value types).
A string value of null
A string value of null
Date object, represented in JSON as "\/Date(number of ticks)\/". The number of ticks is a positive or negative long value that indicates the number of ticks (milliseconds) that have elapsed since midnight 01 January, 1970 UTC.
Enumerations of integer type
Integer equivalent of the enumeration value
Types that implement IEnumerable or System.Collections.Generic.IEnumerable(T) that are not also implementations of IDictionary or System.Collections.Generic.IDictionary(TKey, TValue). This includes types such as Array, ArrayList, and List(T).
Array that uses JSON array syntax
Types that implement IDictionary or System.Collections.Generic.IDictionary(TKey, TValue). This includes types such as Dictionary(TKey, TValue) and Hashtable.
Custom concrete (non-abstract) types that have public instance properties that have get accessors or public instance fields.
Note that public write-only properties, public property or public field attributes marked with ScriptIgnoreAttribute, and public indexed properties in these types are ignored.
String representation of a GUID
String representation of the return value of GetComponents
The first example provides a simple illustration of how to serialize and deserialize data objects. It requires a class names Person which is shown below.
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.