JavaScriptSerializer JavaScriptSerializer JavaScriptSerializer JavaScriptSerializer Constructors

Definition

Overloads

JavaScriptSerializer() JavaScriptSerializer() JavaScriptSerializer()

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

JavaScriptSerializer(JavaScriptTypeResolver) JavaScriptSerializer(JavaScriptTypeResolver) JavaScriptSerializer(JavaScriptTypeResolver) JavaScriptSerializer(JavaScriptTypeResolver)

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

JavaScriptSerializer() JavaScriptSerializer() JavaScriptSerializer()

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

public:
 JavaScriptSerializer();
public JavaScriptSerializer ();
Public Sub New ()

Remarks

An instance of the JavaScriptSerializer class without a type resolver does not include type metadata properties (named "__type") in the serialized JSON string. A type metadata property is used by the Deserialize and DeserializeObject methods to determine the appropriate managed type to which the JSON string will be converted. For information about type resolvers, see the JavaScriptTypeResolver class.

JavaScriptSerializer(JavaScriptTypeResolver) JavaScriptSerializer(JavaScriptTypeResolver) JavaScriptSerializer(JavaScriptTypeResolver) JavaScriptSerializer(JavaScriptTypeResolver)

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

public:
 JavaScriptSerializer(System::Web::Script::Serialization::JavaScriptTypeResolver ^ resolver);
public JavaScriptSerializer (System.Web.Script.Serialization.JavaScriptTypeResolver resolver);
new System.Web.Script.Serialization.JavaScriptSerializer : System.Web.Script.Serialization.JavaScriptTypeResolver -> System.Web.Script.Serialization.JavaScriptSerializer
Public Sub New (resolver As JavaScriptTypeResolver)

Parameters

Remarks

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.

Important

Using an instance of this object initialized with a custom type-resolver can present a security risk. Use this object only with trusted data. For more information, see Data Validation.

See also

Applies to