JavaScriptSerializer::Serialize Method (Object^, StringBuilder^)
Serializes an object and writes the resulting JSON string to the specified StringBuilder object.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
Parameters
- obj
-
Type:
System::Object^
The object to serialize.
- output
-
Type:
System.Text::StringBuilder^
The StringBuilder object that is used to write the JSON string.
| Exception | Condition |
|---|---|
| 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. |
When the JavaScriptSerializer instance is serializing a type for which a custom converter is registered, the serializer calls the Serialize method to obtain the dictionary of name/value pairs that 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 caused converter recursion.
Available since 3.5