DataContractJsonSerializer.WriteObject DataContractJsonSerializer.WriteObject DataContractJsonSerializer.WriteObject DataContractJsonSerializer.WriteObject Method

Definition

Serializes an object to a JavaScript Object Notation (JSON) document.

Overloads

WriteObject(Stream, Object) WriteObject(Stream, Object) WriteObject(Stream, Object)

Serializes a specified object to JavaScript Object Notation (JSON) data and writes the resulting JSON to a stream.

WriteObject(XmlDictionaryWriter, Object) WriteObject(XmlDictionaryWriter, Object) WriteObject(XmlDictionaryWriter, Object) WriteObject(XmlDictionaryWriter, Object)

Serializes an object to XML that may be mapped to JavaScript Object Notation (JSON). Writes all the object data, including the starting XML element, content, and closing element, with an XmlDictionaryWriter.

WriteObject(XmlWriter, Object) WriteObject(XmlWriter, Object) WriteObject(XmlWriter, Object) WriteObject(XmlWriter, Object)

Serializes an object to XML that may be mapped to JavaScript Object Notation (JSON). Writes all the object data, including the starting XML element, content, and closing element, with an XmlWriter.

WriteObject(Stream, Object) WriteObject(Stream, Object) WriteObject(Stream, Object)

Serializes a specified object to JavaScript Object Notation (JSON) data and writes the resulting JSON to a stream.

public:
 override void WriteObject(System::IO::Stream ^ stream, System::Object ^ graph);
public override void WriteObject (System.IO.Stream stream, object graph);
override this.WriteObject : System.IO.Stream * obj -> unit

Parameters

stream
Stream Stream Stream Stream

The Stream that is written to.

graph
Object Object Object Object

The object that contains the data to write to the stream.

Exceptions

The type being serialized does not conform to data contract rules. For example, the DataContractAttribute attribute has not been applied to the type.

The maximum number of objects to serialize has been exceeded. Check the MaxItemsInObjectGraph property.

WriteObject(XmlDictionaryWriter, Object) WriteObject(XmlDictionaryWriter, Object) WriteObject(XmlDictionaryWriter, Object) WriteObject(XmlDictionaryWriter, Object)

Serializes an object to XML that may be mapped to JavaScript Object Notation (JSON). Writes all the object data, including the starting XML element, content, and closing element, with an XmlDictionaryWriter.

public:
 override void WriteObject(System::Xml::XmlDictionaryWriter ^ writer, System::Object ^ graph);
public override void WriteObject (System.Xml.XmlDictionaryWriter writer, object graph);
override this.WriteObject : System.Xml.XmlDictionaryWriter * obj -> unit
Public Overrides Sub WriteObject (writer As XmlDictionaryWriter, graph As Object)

Parameters

writer
XmlDictionaryWriter XmlDictionaryWriter XmlDictionaryWriter XmlDictionaryWriter

The XmlDictionaryWriter used to write the XML document or stream to map to JSON.

graph
Object Object Object Object

The object that contains the data to write.

Exceptions

The type being serialized does not conform to data contract rules. For example, the DataContractAttribute attribute has not been applied to the type.

The maximum number of objects to serialize has been exceeded. Check the MaxItemsInObjectGraph property.

WriteObject(XmlWriter, Object) WriteObject(XmlWriter, Object) WriteObject(XmlWriter, Object) WriteObject(XmlWriter, Object)

Serializes an object to XML that may be mapped to JavaScript Object Notation (JSON). Writes all the object data, including the starting XML element, content, and closing element, with an XmlWriter.

public:
 override void WriteObject(System::Xml::XmlWriter ^ writer, System::Object ^ graph);
public override void WriteObject (System.Xml.XmlWriter writer, object graph);
override this.WriteObject : System.Xml.XmlWriter * obj -> unit
Public Overrides Sub WriteObject (writer As XmlWriter, graph As Object)

Parameters

writer
XmlWriter XmlWriter XmlWriter XmlWriter

The XmlWriter used to write the XML document to map to JSON.

graph
Object Object Object Object

The object that contains the data to write.

Exceptions

The type being serialized does not conform to data contract rules. For example, the DataContractAttribute attribute has not been applied to the type.

The maximum number of objects to serialize has been exceeded. Check the MaxItemsInObjectGraph property.

Applies to