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, output)

Serializes a given Object and writes the resulting JavaScript Object Notation (JSON) string to the specified StringBuilder.

Syntax

CSharp

public void Serialize (
	Object obj,
	StringBuilder output
)

VisualBasic

Public Sub Serialize ( _
	obj As Object, _
	output As StringBuilder _
)

ManagedCPlusPlus

public:
void Serialize (
	Object^ obj, 
	StringBuilder^ output
)

JSharp

public void Serialize (
	Object obj,
	StringBuilder output
)

Parameters

obj (Object)

The Object to serialize.

output (StringBuilder)

The StringBuilder used to write the 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.

ArgumentNullException

output is null.

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