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)

Converts a given Object to a JavaScript Object Notation (JSON) string.

Syntax

CSharp

public string Serialize (
	Object obj
)

VisualBasic

Public Function Serialize ( _
	obj As Object _
) As String

ManagedCPlusPlus

public:
String^ Serialize (
	Object^ obj
)

JSharp

public String Serialize (
	Object obj
)

Parameters

obj (Object)

The Object to serialize.

Return Value

Return Value

The serialized JSON string.

Remarks

When the JavaScriptSerializer instance is serializing a type for which it has a custom converter registered, the serializer calls the Serialize(Object, JavaScriptSerializer) method to obtain the dictionary of name/value pairs which will be converted to a JSON string.

The Serialize method can also throw exceptions if the object graph is too complex or if registered instances of JavaScriptConverter have incorrectly caused converter recursion.

Exceptions

ExceptionCondition
InvalidOperationException

The resulting JSON string exceeds the value of MaxJsonLength.

-or-

obj contains a circular reference. A circular reference occurs when a child object has a reference to a parent object, and the parent object has a reference to the child object.

ArgumentException

The recursion limit defined by RecursionLimit was exceeded.

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