Export (0) Print
Expand All

JavaScriptSerializer.Deserialize(Of T) Method (String)

Converts the specified JSON string to an object of type T.

Namespace:  System.Web.Script.Serialization
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

Public Function Deserialize(Of T) ( _
	input As String _
) As T

Type Parameters


The type of the resulting object.


Type: System.String

The JSON string to be deserialized.

Return Value

Type: T
The deserialized object.


The input length exceeds the value of MaxJsonLength.


The recursion limit defined by RecursionLimit was exceeded.


input contains an unexpected character sequence.


input is a dictionary type and a non-string key value was encountered.


input includes member definitions that are not available on type T.


input is Nothing.


input contains a "__type" property that indicates a custom type, but the type resolver associated with the serializer cannot find a corresponding managed type.


input contains a "__type" property that indicates a custom type, but the result of deserializing the corresponding JSON string cannot be assigned to the expected target type.


input contains a "__type" property that indicates either Object or a non-instantiable type (for example, an abstract types or an interface).


An attempt was made to convert a JSON array to an array-like managed type that is not supported for use as a JSON deserialization target.


It is not possible to convert input to T.

The Deserialize method is equivalent to first using the DeserializeObject method to obtain an object graph and then trying to cast the result to type T.

During deserialization, the serializer’s current type resolver is referenced, which determines the managed type to use when converting elements that are nested inside arrays and dictionary types. As a result, the deserialization process iterates through all nested elements of input. For more information about type resolvers, see the JavaScriptTypeResolver class.

The following example provides a simple illustration of how to serialize and deserialize data objects. It requires a class names Person which is shown below.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5

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.

© 2014 Microsoft