ClassReportJsonSerializer
Serializes and deserializes objects into and from JSON. This class is dedicated for serializing and deserializing objects only from the Telerik.Reporting namespace.
Definition
Namespace:Telerik.Reporting.JsonSerialization
Assembly:Telerik.Reporting.JsonSerialization.dll
Syntax:
public class ReportJsonSerializer
Inheritance: objectReportJsonSerializer
Constructors
ReportJsonSerializer()
Initializes a new instance of the ReportJsonSerializer class.
Declaration
public ReportJsonSerializer()
Methods
Deserialize(Stream)
Deserializes the JSON document contained by the specified Stream.
Declaration
public IReportDocument Deserialize(Stream stream)
Parameters
stream
Stream
The Stream that contains the JSON document to deserialize.
Returns
The Telerik.Reporting object being deserialized.
Remarks
Use the stream parameter to specify an object that derives from the Stream class, which is designed to write to streams. Classes that derive from the Stream class include: BufferedStream, FileStream, MemoryStream, etc.
Example
The following example deserializes an object using a Stream:
using (System.IO.FileStream fileStream = new System.IO.FileStream("Report1.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
Telerik.Reporting.Report report = (Telerik.Reporting.Report)
xmlSerializer.Deserialize(fileStream);
}
Using fileStream As New System.IO.FileStream("Report1.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim xmlSerializer As New Telerik.Reporting.XmlSerialization.ReportXmlSerializer()
Dim report As Telerik.Reporting.Report = DirectCast(xmlSerializer.Deserialize(fileStream), Telerik.Reporting.Report)
End Using
Deserialize(string)
Deserializes the JSON string to a report document.
Declaration
public IReportDocument Deserialize(string value)
Parameters
value
string
The string that contains the JSON document.
Returns
The IReportDocument object being deserialized.
Deserialize<T>(string)
Deserializes the JSON string to a specified instance of T.
Declaration
public T Deserialize<T>(string value) where T : class
Parameters
value
string
The string that contains the JSON document.
Returns
T
The Telerik.Reporting object being deserialized.
Serialize(TextWriter, object, Formatting)
Serializes the specified value and writes the JSON document to the specified TextWriter.
Declaration
public void Serialize(TextWriter writer, object value, Formatting formatting = 0)
Parameters
writer
TextWriter
The TextWriter used to write the JSON document.
value
object
The value to serialize.
formatting
Formatting
Specifies formatting options for the JsonTextWriter. Default is Formatting.None.