Export (0) Print
Expand All

JavaScriptSerializer.RegisterConverters Method

Registers a custom converter with the JavaScriptSerializer instance.

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

'Declaration
Public Sub RegisterConverters ( _
	converters As IEnumerable(Of JavaScriptConverter) _
)

Parameters

converters
Type: System.Collections.Generic.IEnumerable(Of JavaScriptConverter)

An array that contains the custom converters to be registered.

ExceptionCondition
ArgumentNullException

converters is Nothing.

You can register one or more custom converters with a JavaScriptSerializer instance by using the RegisterConverters method. When custom converters are registered, JavaScriptSerializer uses the converters both to serialize managed types and to deserialize JSON strings to managed types.

Multiple converters can be registered with the same JavaScriptSerializer instance, and these converters can indicate support for the same type. As a result, the last converter that is registered for a specific type is the one that will be used by JavaScriptSerializer to serialize the type.

For more information about custom converters, see the JavaScriptConverter class.

The following example shows how to register a custom converter with a JavaScriptSerializer instance. This code example is part of a larger example provided for the JavaScriptSerializer class.

serializer = New JavaScriptSerializer()

' Register the custom converter.
serializer.RegisterConverters(New JavaScriptConverter() _
    {New System.Web.Script.Serialization.VB.ListItemCollectionConverter()})

.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.

Show:
© 2014 Microsoft