DataContractJsonSerializer Class
 

Serializes objects to the JavaScript Object Notation (JSON) and deserializes JSON data to objects. This class cannot be inherited.

Namespace:   System.Runtime.Serialization.Json
Assembly:  System.Runtime.Serialization (in System.Runtime.Serialization.dll)

SystemObject
   System.Runtime.SerializationXmlObjectSerializer
    System.Runtime.Serialization.JsonDataContractJsonSerializer

public sealed class DataContractJsonSerializer : XmlObjectSerializer
public ref class DataContractJsonSerializer sealed : XmlObjectSerializer
[<Sealed>]
type DataContractJsonSerializer = 
    class
        inherit XmlObjectSerializer
    end
Public NotInheritable Class DataContractJsonSerializer
	Inherits XmlObjectSerializer
NameDescription
System_CAPS_pubmethod DataContractJsonSerializer

Initializes a new instance of the DataContractJsonSerializer class to serialize or deserialize an object of the specified type.

System_CAPS_pubmethod DataContractJsonSerializer

Initializes a new instance of the DataContractJsonSerializer class to serialize or deserialize an object of the specified type and serializer settings.

System_CAPS_pubmethod DataContractJsonSerializer

Initializes a new instance of the DataContractJsonSerializer class to serialize or deserialize an object of the specified type, with a collection of known types that may be present in the object graph.

System_CAPS_pubmethod DataContractJsonSerializer

Initializes a new instance of the DataContractJsonSerializer class to serialize or deserialize an object of the specified type. This method also specifies a list of known types that may be present in the object graph, the maximum number of graph items to serialize or deserialize, whether to ignore unexpected data or emit type information, and a surrogate for custom serialization.

System_CAPS_pubmethod DataContractJsonSerializer

Initializes a new instance of the DataContractJsonSerializer class to serialize or deserialize an object of a specified type using the XML root element specified by a parameter.

System_CAPS_pubmethod DataContractJsonSerializer

Initializes a new instance of the DataContractJsonSerializer class to serialize or deserialize an object of a specified type using the XML root element specified by a parameter, with a collection of known types that may be present in the object graph.

System_CAPS_pubmethod DataContractJsonSerializer

Initializes a new instance of the DataContractJsonSerializer class to serialize or deserialize an object of the specified type. This method also specifies the root name of the XML element, a list of known types that may be present in the object graph, the maximum number of graph items to serialize or deserialize, whether to ignore unexpected data or emit type information, and a surrogate for custom serialization.

System_CAPS_pubmethod DataContractJsonSerializer

Initializes a new instance of the DataContractJsonSerializer class to serialize or deserialize an object of a specified type using the XML root element specified by a parameter of type XmlDictionaryString.

System_CAPS_pubmethod DataContractJsonSerializer

Initializes a new instance of the DataContractJsonSerializer class to serialize or deserialize an object of a specified type using the XML root element specified by a parameter of type XmlDictionaryString, with a collection of known types that may be present in the object graph.

System_CAPS_pubmethod DataContractJsonSerializer

Initializes a new instance of the DataContractJsonSerializer class to serialize or deserialize an object of the specified type. This method also specifies the root name of the XML element, a list of known types that may be present in the object graph, the maximum number of graph items to serialize or deserialize, whether to ignore unexpected data or emit type information, and a surrogate for custom serialization.

NameDescription
System_CAPS_pubproperty

Gets a surrogate type that is currently active for a given IDataContractSurrogate instance. Surrogates can extend the serialization or deserialization process.

System_CAPS_pubproperty

Gets the format of the date and time type items in object graph.

System_CAPS_pubproperty

Gets or sets the data contract JSON serializer settings to emit type information.

System_CAPS_pubproperty

Gets a value that specifies whether unknown data is ignored on deserialization and whether the IExtensibleDataObject interface is ignored on serialization.

System_CAPS_pubproperty

Gets a collection of types that may be present in the object graph serialized using this instance of the DataContractJsonSerializer.

System_CAPS_pubproperty

Gets the maximum number of items in an object graph that the serializer serializes or deserializes in one read or write call.

System_CAPS_pubproperty

Gets or sets a value that specifies whether to serialize read only types.

System_CAPS_pubproperty

Gets or sets a value that specifies whether to use a simple dictionary format.

NameDescription
System_CAPS_pubmethod Equals

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethod GetHashCode

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethod GetType

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethod IsStartObject

Gets a value that specifies whether the XmlDictionaryReader is positioned over an XML element that represents an object the serializer can deserialize from.(Overrides XmlObjectSerializerIsStartObject.)

System_CAPS_pubmethod IsStartObject

Determines whether the XmlReader is positioned on an object that can be deserialized.(Overrides XmlObjectSerializerIsStartObject.)

System_CAPS_pubmethod ReadObject

Reads a document stream in the JSON (JavaScript Object Notation) format and returns the deserialized object.(Overrides XmlObjectSerializerReadObject.)

System_CAPS_pubmethod ReadObject

Reads the XML document mapped from JSON (JavaScript Object Notation) with an XmlDictionaryReader and returns the deserialized object.(Overrides XmlObjectSerializerReadObject.)

System_CAPS_pubmethod ReadObject

Reads the XML document mapped from JSON with an XmlDictionaryReader and returns the deserialized object; it also enables you to specify whether the serializer should verify that it is positioned on an appropriate element before attempting to deserialize.(Overrides XmlObjectSerializerReadObject.)

System_CAPS_pubmethod ReadObject

Reads the XML document mapped from JSON (JavaScript Object Notation) with an XmlReader and returns the deserialized object.(Overrides XmlObjectSerializerReadObject.)

System_CAPS_pubmethod ReadObject

Reads an XML document mapped from JSON with an XmlReader and returns the deserialized object; it also enables you to specify whether the serializer should verify that it is positioned on an appropriate element before attempting to deserialize.(Overrides XmlObjectSerializerReadObject.)

System_CAPS_pubmethod ToString

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethod WriteEndObject

Writes the closing XML element to an XML document, using an XmlDictionaryWriter, which can be mapped to JavaScript Object Notation (JSON).(Overrides XmlObjectSerializerWriteEndObject.)

System_CAPS_pubmethod WriteEndObject

Writes the closing XML element to an XML document, using an XmlWriter, which can be mapped to JavaScript Object Notation (JSON).(Overrides XmlObjectSerializerWriteEndObject.)

System_CAPS_pubmethod WriteObject

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

System_CAPS_pubmethod WriteObject

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.(Overrides XmlObjectSerializerWriteObject.)

System_CAPS_pubmethod WriteObject

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.(Overrides XmlObjectSerializerWriteObject.)

System_CAPS_pubmethod WriteObjectContent

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

System_CAPS_pubmethod WriteObjectContent

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

System_CAPS_pubmethod WriteStartObject

Writes the opening XML element for serializing an object to XML that can be mapped to JavaScript Object Notation (JSON) using an XmlDictionaryWriter.(Overrides XmlObjectSerializerWriteStartObject.)

System_CAPS_pubmethod WriteStartObject

Writes the opening XML element for serializing an object to XML that can be mapped to JavaScript Object Notation (JSON) using an XmlWriter.(Overrides XmlObjectSerializerWriteStartObject.)

Use the DataContractJsonSerializer class to serialize instances of a type into a JSON document and to deserialize a JSON document into an instance of a type. For example, you can create a type named Person with properties that contain essential data, such as a name and address. You can then create and manipulate an instance of the Person class and write all of its property values in a JSON document for later retrieval. This JSON document can later be deserialized into the Person class or another class with an equivalent data contract.

If an error occurs during the serialization of an outgoing reply on the server or the reply operation throws an exception for some other reason, it may not get returned to the client as a fault.

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top