Bagikan melalui


JsonReaderWriterFactory Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Produces instances of XmlDictionaryReader that can read data encoded with JavaScript Object Notation (JSON) from a stream or buffer and map it to an XML Infoset, and produces instances of XmlDictionaryWriter that can map an XML Infoset to JSON and write JSON-encoded data to a stream.

Inheritance Hierarchy

System.Object
  System.Runtime.Serialization.Json.JsonReaderWriterFactory

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

Syntax

'Declaration
Public NotInheritable Class JsonReaderWriterFactory
public static class JsonReaderWriterFactory

Methods

  Name Description
Public methodStatic member CreateJsonReader(array<Byte[], XmlDictionaryReaderQuotas) Creates an XmlDictionaryReader that can map a specified buffer encoded with JavaScript Object Notation (JSON) to an XML Infoset.
Public methodStatic member CreateJsonReader(Stream, XmlDictionaryReaderQuotas) Creates an XmlDictionaryReader that can map a specified stream encoded with JavaScript Object Notation (JSON) to an XML Infoset.
Public methodStatic member CreateJsonReader(array<Byte[], Int32, Int32, XmlDictionaryReaderQuotas) Creates an XmlDictionaryReader that can map a buffer encoded with JavaScript Object Notation (JSON), of a specified size and offset, to an XML Infoset.
Public methodStatic member CreateJsonWriter(Stream) Creates an XmlDictionaryWriter that writes data encoded with JSON to a stream using a UTF-8 character encoding.
Public methodStatic member CreateJsonWriter(Stream, Encoding) Creates an XmlDictionaryWriter that writes data encoded with JSON to a stream with a specified character encoding.
Public methodStatic member CreateJsonWriter(Stream, Encoding, Boolean) Creates an XmlDictionaryWriter that writes data encoded with JSON to a stream with a specified character encoding and that specifies whether the output stream is closed by the writer when it is done.

Top

Remarks

Silverlight 5 processes JSON messages using a mapping between JSON data and the XML Infoset. Normally, this mapping is hidden from view. However, in some advanced scenarios it might be necessary to manually convert between JSON and XML. In this case, the JsonReaderWriterFactory class can be used to create the necessary XML readers and writers. Note that not every XML Infoset element can be mapped to JSON.

For more information about

mapping, see Mapping between JSON and XML.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

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