JavaScriptConverter::Deserialize Method (IDictionary<String^, Object^>^, Type^, JavaScriptSerializer^)

 

When overridden in a derived class, converts the provided dictionary into an object of the specified type.

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

public:
virtual Object^ Deserialize(
	IDictionary<String^, Object^>^ dictionary,
	Type^ type,
	JavaScriptSerializer^ serializer
) abstract

Parameters

dictionary
Type: System.Collections.Generic::IDictionary<String^, Object^>^

An IDictionary<TKey, TValue> instance of property data stored as name/value pairs.

type
Type: System::Type^

The type of the resulting object.

serializer
Type: System.Web.Script.Serialization::JavaScriptSerializer^

The JavaScriptSerializer instance.

Return Value

Type: System::Object^

The deserialized object.

Notes to Inheritors:

The Deserialize method iterates through the values in the dictionary parameter to construct an instance of the type requested in the type parameter. Although a converter can directly use values from dictionary, we recommend that the converter implementer use the ConvertToType<T> method instead. The converter should call this method of the JavaScriptSerializer instance available from the serializer parameter.

The ConvertToType<T> method enables converter to pass a property value from dictionary, and then return a value of the expected type. In some cases, a converter for a custom type might be working with properties that themselves have registered converters (for example, type A has a property of type B, and type B is also associated with a custom converter). In that case, invoking ConvertToType<T> makes sure that custom converters will be recursively invoked for property data that is contained in the dictionary. When the converter has iterated through all entries in the dictionary, it returns a constructed instance of the target type.

If the converter encounters a problem during deserialization, it should throw an InvalidOperationException error that describes the problem.

.NET Framework
Available since 3.5
Return to top
Show: