Show / Hide Table of Contents

Class JSONWriter

Writes primitive types, JSONDataObjects, JSONDynamicObjects, IEnumerable and IDictionary - implementers into string or stream. Can also write IJSONWritable-implementing types that directly serialize their state into JSON. This class does not serialize regular CLR types (that do not implement IJSONWritable), use JSONSerializer for full functionality

Inheritance
System.Object
JSONWriter
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: NFX.Serialization.JSON
Assembly: NFX.dll
Syntax
public static class JSONWriter

Methods

EncodeDateTime(TextWriter, DateTime, JSONWritingOptions, Nullable<TimeSpan>)

Writes a string in JSON format (a la "JSON encode string") - using quotes and escaping charecters that need it

Declaration
public static void EncodeDateTime(TextWriter wri, DateTime data, JSONWritingOptions opt = null, TimeSpan? utcOffset = default (TimeSpan? ))
Parameters
Type Name Description
System.IO.TextWriter wri

TextWriter instance to append data into

System.DateTime data

Original string to encode as JSON

JSONWritingOptions opt

JSONWriting options instance, if omitted then JSONWritingOptions.Compact is used

System.Nullable<System.TimeSpan> utcOffset

UTC offset override. If not supplied then offset form local time zone is used

EncodeString(TextWriter, String, JSONWritingOptions)

Writes a string in JSON format (a la "JSON encode string") - using quotes and escaping charecters that need it

Declaration
public static void EncodeString(TextWriter wri, string data, JSONWritingOptions opt = null)
Parameters
Type Name Description
System.IO.TextWriter wri

TextWriter instance to append data into

System.String data

Original string to encode as JSON

JSONWritingOptions opt

JSONWriting options instance, if omitted then JSONWritingOptions.Compact is used

Write(Object, JSONWritingOptions, IFormatProvider)

Writes JSON data to the string

Declaration
public static string Write(object data, JSONWritingOptions options = null, IFormatProvider formatProvider = null)
Parameters
Type Name Description
System.Object data
JSONWritingOptions options
System.IFormatProvider formatProvider
Returns
Type Description
System.String

Write(Object, Stream, JSONWritingOptions, Encoding)

Writes JSON data to the stream

Declaration
public static void Write(object data, Stream stream, JSONWritingOptions options = null, Encoding encoding = null)
Parameters
Type Name Description
System.Object data
System.IO.Stream stream
JSONWritingOptions options
System.Text.Encoding encoding

Write(Object, TextWriter, JSONWritingOptions)

Appends JSON data into the instance of StringBuilder

Declaration
public static void Write(object data, TextWriter wri, JSONWritingOptions options = null)
Parameters
Type Name Description
System.Object data
System.IO.TextWriter wri
JSONWritingOptions options

WriteArray(TextWriter, IEnumerable, Int32, JSONWritingOptions)

Appends JSON representation of an IEnumerable

Declaration
public static void WriteArray(TextWriter wri, IEnumerable data, int level, JSONWritingOptions options)
Parameters
Type Name Description
System.IO.TextWriter wri
System.Collections.IEnumerable data
System.Int32 level
JSONWritingOptions options

WriteMap(TextWriter, IEnumerable<DictionaryEntry>, Int32, JSONWritingOptions)

Appends JSON representation of a map(IEnumerable(DictionaryEntry))

Declaration
public static void WriteMap(TextWriter wri, IEnumerable<DictionaryEntry> data, int level, JSONWritingOptions options = null)
Parameters
Type Name Description
System.IO.TextWriter wri
System.Collections.Generic.IEnumerable<System.Collections.DictionaryEntry> data
System.Int32 level
JSONWritingOptions options

WriteMap(TextWriter, IDictionary, Int32, JSONWritingOptions)

Appends JSON representation of a map(IDictionary)

Declaration
public static void WriteMap(TextWriter wri, IDictionary data, int level, JSONWritingOptions options = null)
Parameters
Type Name Description
System.IO.TextWriter wri
System.Collections.IDictionary data
System.Int32 level
JSONWritingOptions options

WriteMap(TextWriter, Int32, JSONWritingOptions, DictionaryEntry[])

Appends JSON representation of a map(IEnumerable(DictionaryEntry))

Declaration
public static void WriteMap(TextWriter wri, int level, JSONWritingOptions options, params DictionaryEntry[] data)
Parameters
Type Name Description
System.IO.TextWriter wri
System.Int32 level
JSONWritingOptions options
System.Collections.DictionaryEntry[] data

WriteToBuffer(Object, JSONWritingOptions, Encoding)

Writes JSON data to the byte[]

Declaration
public static byte[] WriteToBuffer(object data, JSONWritingOptions options = null, Encoding encoding = null)
Parameters
Type Name Description
System.Object data
JSONWritingOptions options
System.Text.Encoding encoding
Returns
Type Description
System.Byte[]

WriteToFile(Object, String, JSONWritingOptions, Encoding)

Writes JSON data to the file

Declaration
public static void WriteToFile(object data, string fileName, JSONWritingOptions options = null, Encoding encoding = null)
Parameters
Type Name Description
System.Object data
System.String fileName
JSONWritingOptions options
System.Text.Encoding encoding
Back to top Copyright © 2006-2018 Agnicore Inc
Generated by DocFX