Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Deserialize Method (input)

Converts the specified JavaScript Object Notation (JSON) string to an object of type T.

Syntax

CSharp

public T Deserialize<T> (
	string input
)

VisualBasic

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

ManagedCPlusPlus

public:
generic<typename T>
T Deserialize (
	String^ input
)

JSharp

J# supports the use of generic APIs, but not the declaration of new ones.

Generic Template Parameters

T

The type of the resulting object.

Parameters

input (String)

The JSON string to be deserialized.

Return Value

Return Value

The deserialized object.

Remarks

The Deserialize<(Of T>)(String) method is equivalent to first using the DeserializeObject(String) 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 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.

Exceptions

ExceptionCondition
ArgumentException

The input length exceeds MaxJsonLength.

-or-

The recursion limit defined by RecursionLimit was exceeded.

-or-

input contains an unexpected character sequence.

-or-

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

-or-

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

ArgumentNullException

input is null.

InvalidOperationException

input contains a “__type” tag indicating a custom type, but the type resolver currently associated with the serializer cannot find a corresponding managed type.

-or-

input contains a “__type” tag indicating a custom type, but the result of deserializing the corresponding JSON string cannot be assigned to the expected target type.

-or-

input contains a “__type” tag indicating either Object or a non-instantiable type (for example, abstract types and interfaces).

-or-

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

-or-

It is not possible to convert input to T.

Assembly: System.Web.Extensions (Module: System.Web.Extensions)