This documentation is archived and is not being maintained.

JavaScriptSerializer Constructor (JavaScriptTypeResolver)

NOTE: This API is now obsolete.

Initializes a new instance of the JavaScriptSerializer class that has a custom type resolver.

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

[ObsoleteAttribute("The recommended alternative is System.Runtime.Serialization.DataContractJsonSerializer.")]
public JavaScriptSerializer(
	JavaScriptTypeResolver resolver
)

Parameters

resolver
Type: System.Web.Script.Serialization.JavaScriptTypeResolver

The custom type-resolver object.

When it is serializing an object, the JavaScriptSerializer class uses the resolver parameter to determine the appropriate value to include in the serialized JSON string for the type metadata property ("__type"). Similarly, when the JavaScriptSerializer class is deserializing a JSON string, it resolves the type metadata property value to the appropriate managed type by using the resolver instance.

You can set the resolver parameter to null, which is equivalent to calling the JavaScriptSerializer constructor.

The instance of JavaScriptSerializer that is used by the asynchronous communication layer for invoking Web services from client script uses a special type resolver. This type resolver restricts the types that can be deserialized to those defined in the Web service’s method signature, or the ones that have the GenerateScriptTypeAttribute applied. You cannot modify this built-in type resolver programmatically.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1
Obsolete (compiler warning) in 3.5
Show: