DataContractJsonSerializer.WriteObjectContent Method

Definition

Writes the content of an object to XML that may be mapped to JavaScript Object Notation (JSON) without writing the wrapping element.

Overloads

WriteObjectContent(XmlDictionaryWriter, Object)

Writes the XML content that can be mapped to JavaScript Object Notation (JSON) using an XmlDictionaryWriter.

WriteObjectContent(XmlWriter, Object)

Writes the XML content that can be mapped to JavaScript Object Notation (JSON) using an XmlWriter.

WriteObjectContent(XmlDictionaryWriter, Object)

Source:
DataContractJsonSerializer.cs
Source:
DataContractJsonSerializer.cs
Source:
DataContractJsonSerializer.cs

Writes the XML content that can be mapped to JavaScript Object Notation (JSON) using an XmlDictionaryWriter.

public override void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object? graph);
public override void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object graph);

Parameters

writer
XmlDictionaryWriter

The XmlDictionaryWriter to write to.

graph
Object

The object 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.

There is a problem with the instance being written.

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

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

WriteObjectContent(XmlWriter, Object)

Source:
DataContractJsonSerializer.cs
Source:
DataContractJsonSerializer.cs
Source:
DataContractJsonSerializer.cs

Writes the XML content that can be mapped to JavaScript Object Notation (JSON) using an XmlWriter.

public override void WriteObjectContent(System.Xml.XmlWriter writer, object? graph);
public override void WriteObjectContent(System.Xml.XmlWriter writer, object graph);

Parameters

writer
XmlWriter

The XmlWriter used to write to.

graph
Object

The object 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.

There is a problem with the instance being written.

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

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1