Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.








Serialize Method (obj, serializer)

When overridden in a derived class, builds a dictionary of name/value pairs.



public abstract IDictionary<string, Object> Serialize (
	Object obj,
	JavaScriptSerializer serializer


Public MustOverride Function Serialize ( _
	obj As Object, _
	serializer As JavaScriptSerializer _
) As IDictionary(Of String, Object)


virtual IDictionary<String^, Object^>^ Serialize (
	Object^ obj, 
	JavaScriptSerializer^ serializer
) abstract


public abstract IDictionary<String, Object> Serialize (
	Object obj,
	JavaScriptSerializer serializer


obj (Object)

The Object to serialize.

serializer (JavaScriptSerializer)

The JavaScriptSerializer responsible for the serialization.

Return Value

Return Value

An IDictionary object that contains key/value pairs that represent the object’s data.


When serializing a type for which a custom converter is registered, the JavaScriptSerializer instance will invoke the Serialize(Object, JavaScriptSerializer) method.

Notes For Inheritors

The return value of Serialize(Object, JavaScriptSerializer) must be an IDictionary instance with zero or more name/value pairs that represent an object’s data that will be converted to JSON. Note that the converter itself does not serialize data as JSON. Instead, the converter builds a dictionary of name/value pairs that contain the property names (the string key for the dictionary) and corresponding property values (the object value in the dictionary). The JavaScriptSerializer instance subsequently converts these to JSON.

If the converter encounters an exception, it should throw an InvalidOperationException that describes the problem.

Assembly: System.Web.Extensions (Module: System.Web.Extensions)