Syntax
CSharp
VisualBasic
ManagedCPlusPlus
JSharp
Parameters
- converters (IEnumerable<(Of JavaScriptConverter>))
An array of type JavaScriptConverter that contains the custom converters to be registered.
Remarks
You can register one or more custom converters with a JavaScriptSerializer instance by using the RegisterConverters(IEnumerable<(Of JavaScriptConverter>)) method. When custom converters are registered, JavaScriptSerializer uses the converters as part of both the serialization of managed types and the deserialization of JavaScript Object Notation (JSON) strings back to managed types.
Multiple converters can be registered against the same JavaScriptSerializer instance, and these converters might 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.
Examples
The following example demonstrates how to register a custom converter with a JavaScriptSerializer instance. This code example is part of a larger example provided for the JavaScriptSerializer class.
CS
serializer = new JavaScriptSerializer();
// Register the custom converter.
serializer.RegisterConverters(new JavaScriptConverter[] {
new System.Web.Script.Serialization.CS.ListItemCollectionConverter() });
VB
serializer = New JavaScriptSerializer()
' Register the custom converter.
serializer.RegisterConverters(New JavaScriptConverter() _
{New System.Web.Script.Serialization.VB.ListItemCollectionConverter()})
Exceptions
Assembly: System.Web.Extensions (Module: System.Web.Extensions)