Class JsonSerializer
Serializes and deserializes objects into and from the JSON format.
The JsonSerializer enables you to control how objects are encoded into JSON.
Inheritance
System.Object
JsonSerializer
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()
Assembly : Bayat.Json.Runtime.dll
Syntax
public class JsonSerializer
Constructors
|
Improve this Doc
View Source
JsonSerializer()
Declaration
Fields
|
Improve this Doc
View Source
_binder
Declaration
protected SerializationBinder _binder
Field Value
Type
Description
System.Runtime.Serialization.SerializationBinder
|
Improve this Doc
View Source
_checkAdditionalContent
Declaration
protected bool? _checkAdditionalContent
Field Value
Type
Description
System.Nullable <System.Boolean >
|
Improve this Doc
View Source
_constructorHandling
Declaration
protected ConstructorHandling _constructorHandling
Field Value
|
Improve this Doc
View Source
_context
Declaration
protected StreamingContext _context
Field Value
Type
Description
System.Runtime.Serialization.StreamingContext
|
Improve this Doc
View Source
_contractResolver
Declaration
protected IContractResolver _contractResolver
Field Value
|
Improve this Doc
View Source
_converters
Declaration
protected JsonConverterCollection _converters
Field Value
|
Improve this Doc
View Source
_culture
Declaration
protected CultureInfo _culture
Field Value
Type
Description
System.Globalization.CultureInfo
|
Improve this Doc
View Source
Declaration
protected DateFormatHandling? _dateFormatHandling
Field Value
|
Improve this Doc
View Source
Declaration
protected string _dateFormatString
Field Value
Type
Description
System.String
|
Improve this Doc
View Source
Declaration
protected bool _dateFormatStringSet
Field Value
Type
Description
System.Boolean
|
Improve this Doc
View Source
_dateParseHandling
Declaration
protected DateParseHandling? _dateParseHandling
Field Value
|
Improve this Doc
View Source
_dateTimeZoneHandling
Declaration
protected DateTimeZoneHandling? _dateTimeZoneHandling
Field Value
|
Improve this Doc
View Source
_defaultValueHandling
Declaration
protected DefaultValueHandling _defaultValueHandling
Field Value
|
Improve this Doc
View Source
_equalityComparer
Declaration
protected IEqualityComparer _equalityComparer
Field Value
Type
Description
System.Collections.IEqualityComparer
|
Improve this Doc
View Source
Declaration
protected FloatFormatHandling? _floatFormatHandling
Field Value
|
Improve this Doc
View Source
_floatParseHandling
Declaration
protected FloatParseHandling? _floatParseHandling
Field Value
|
Improve this Doc
View Source
Declaration
protected Formatting? _formatting
Field Value
|
Improve this Doc
View Source
_maxDepth
Declaration
Field Value
Type
Description
System.Nullable <System.Int32 >
|
Improve this Doc
View Source
_maxDepthSet
Declaration
protected bool _maxDepthSet
Field Value
Type
Description
System.Boolean
|
Improve this Doc
View Source
Declaration
protected MetadataPropertyHandling _metadataPropertyHandling
Field Value
|
Improve this Doc
View Source
_missingMemberHandling
Declaration
protected MissingMemberHandling _missingMemberHandling
Field Value
|
Improve this Doc
View Source
_nullValueHandling
Declaration
protected NullValueHandling _nullValueHandling
Field Value
|
Improve this Doc
View Source
_objectCreationHandling
Declaration
protected ObjectCreationHandling _objectCreationHandling
Field Value
|
Improve this Doc
View Source
_preserveReferencesHandling
Declaration
protected PreserveReferencesHandling _preserveReferencesHandling
Field Value
|
Improve this Doc
View Source
_referenceLoopHandling
Declaration
protected ReferenceLoopHandling _referenceLoopHandling
Field Value
|
Improve this Doc
View Source
_referenceResolver
Declaration
protected IReferenceResolver _referenceResolver
Field Value
|
Improve this Doc
View Source
_serializeScriptableObjects
Declaration
protected bool? _serializeScriptableObjects
Field Value
Type
Description
System.Nullable <System.Boolean >
|
Improve this Doc
View Source
_stringEscapeHandling
Declaration
protected StringEscapeHandling? _stringEscapeHandling
Field Value
|
Improve this Doc
View Source
_traceWriter
Declaration
protected ITraceWriter _traceWriter
Field Value
|
Improve this Doc
View Source
Declaration
protected FormatterAssemblyStyle _typeNameAssemblyFormat
Field Value
Type
Description
System.Runtime.Serialization.Formatters.FormatterAssemblyStyle
|
Improve this Doc
View Source
_typeNameHandling
Declaration
protected TypeNameHandling _typeNameHandling
Field Value
|
Improve this Doc
View Source
AvailableConverters
Declaration
public static readonly JsonConverter[] AvailableConverters
Field Value
Properties
|
Improve this Doc
View Source
Binder
Gets or sets the System.Runtime.Serialization.SerializationBinder used by the serializer when resolving type names.
Declaration
public virtual SerializationBinder Binder { get; set; }
Property Value
Type
Description
System.Runtime.Serialization.SerializationBinder
|
Improve this Doc
View Source
CheckAdditionalContent
Gets a value indicating whether there will be a check for additional JSON content after deserializing an object.
Declaration
public virtual bool CheckAdditionalContent { get; set; }
Property Value
Type
Description
System.Boolean
true
if there will be a check for additional JSON content after deserializing an object; otherwise, false
.
|
Improve this Doc
View Source
ConstructorHandling
Gets or sets how constructors are used during deserialization.
Declaration
public virtual ConstructorHandling ConstructorHandling { get; set; }
Property Value
|
Improve this Doc
View Source
Context
Gets or sets the System.Runtime.Serialization.StreamingContext used by the serializer when invoking serialization callback methods.
Declaration
public virtual StreamingContext Context { get; set; }
Property Value
Type
Description
System.Runtime.Serialization.StreamingContext
The context.
|
Improve this Doc
View Source
ContractResolver
Gets or sets the contract resolver used by the serializer when
serializing .NET objects to JSON and vice versa.
Declaration
public virtual IContractResolver ContractResolver { get; set; }
Property Value
|
Improve this Doc
View Source
Converters
Gets a collection JsonConverter that will be used during serialization.
Declaration
public virtual JsonConverterCollection Converters { get; }
Property Value
|
Improve this Doc
View Source
Culture
Gets or sets the culture used when reading JSON. Defaults to System.Globalization.CultureInfo.InvariantCulture .
Declaration
public virtual CultureInfo Culture { get; set; }
Property Value
Type
Description
System.Globalization.CultureInfo
|
Improve this Doc
View Source
Get or set how dates are written to JSON text.
Declaration
public virtual DateFormatHandling DateFormatHandling { get; set; }
Property Value
|
Improve this Doc
View Source
Get or set how System.DateTime and System.DateTimeOffset values are formatted when writing JSON text, and the expected date format when reading JSON text.
Declaration
public virtual string DateFormatString { get; set; }
Property Value
Type
Description
System.String
|
Improve this Doc
View Source
DateParseHandling
Get or set how date formatted strings, e.g. "/Date(1198908717056)/" and "2012-03-21T05:40Z", are parsed when reading JSON.
Declaration
public virtual DateParseHandling DateParseHandling { get; set; }
Property Value
|
Improve this Doc
View Source
DateTimeZoneHandling
Get or set how System.DateTime time zones are handling during serialization and deserialization.
Declaration
public virtual DateTimeZoneHandling DateTimeZoneHandling { get; set; }
Property Value
|
Improve this Doc
View Source
DefaultValueHandling
Get or set how null default are handled during serialization and deserialization.
Declaration
public virtual DefaultValueHandling DefaultValueHandling { get; set; }
Property Value
|
Improve this Doc
View Source
EqualityComparer
Gets or sets the equality comparer used by the serializer when comparing references.
Declaration
public virtual IEqualityComparer EqualityComparer { get; set; }
Property Value
Type
Description
System.Collections.IEqualityComparer
The equality comparer.
|
Improve this Doc
View Source
Get or set how special floating point numbers, e.g. System.Double.NaN ,
System.Double.PositiveInfinity and System.Double.NegativeInfinity ,
are written as JSON text.
Declaration
public virtual FloatFormatHandling FloatFormatHandling { get; set; }
Property Value
|
Improve this Doc
View Source
FloatParseHandling
Get or set how floating point numbers, e.g. 1.0 and 9.9, are parsed when reading JSON text.
Declaration
public virtual FloatParseHandling FloatParseHandling { get; set; }
Property Value
|
Improve this Doc
View Source
Indicates how JSON text output is formatted.
Declaration
public virtual Formatting Formatting { get; set; }
Property Value
|
Improve this Doc
View Source
MaxDepth
Gets or sets the maximum depth allowed when reading JSON. Reading past this depth will throw a JsonReaderException .
Declaration
public virtual int? MaxDepth { get; set; }
Property Value
Type
Description
System.Nullable <System.Int32 >
|
Improve this Doc
View Source
Gets or sets how metadata properties are used during deserialization.
Declaration
public virtual MetadataPropertyHandling MetadataPropertyHandling { get; set; }
Property Value
|
Improve this Doc
View Source
MissingMemberHandling
Get or set how missing members (e.g. JSON contains a property that isn't a member on the object) are handled during deserialization.
Declaration
public virtual MissingMemberHandling MissingMemberHandling { get; set; }
Property Value
|
Improve this Doc
View Source
NullValueHandling
Get or set how null values are handled during serialization and deserialization.
Declaration
public virtual NullValueHandling NullValueHandling { get; set; }
Property Value
|
Improve this Doc
View Source
ObjectCreationHandling
Gets or sets how objects are created during deserialization.
Declaration
public virtual ObjectCreationHandling ObjectCreationHandling { get; set; }
Property Value
|
Improve this Doc
View Source
PreserveReferencesHandling
Gets or sets how object references are preserved by the serializer.
Declaration
public virtual PreserveReferencesHandling PreserveReferencesHandling { get; set; }
Property Value
|
Improve this Doc
View Source
ReferenceLoopHandling
Get or set how reference loops (e.g. a class referencing itself) is handled.
Declaration
public virtual ReferenceLoopHandling ReferenceLoopHandling { get; set; }
Property Value
|
Improve this Doc
View Source
ReferenceResolver
Declaration
public virtual IReferenceResolver ReferenceResolver { get; set; }
Property Value
|
Improve this Doc
View Source
SerializeScriptableObjects
Gets a value indicating whether to serialize ScriptableObjects data or not.
Declaration
public virtual bool SerializeScriptableObjects { get; set; }
Property Value
Type
Description
System.Boolean
|
Improve this Doc
View Source
StringEscapeHandling
Get or set how strings are escaped when writing JSON text.
Declaration
public virtual StringEscapeHandling StringEscapeHandling { get; set; }
Property Value
|
Improve this Doc
View Source
TraceWriter
Gets or sets the ITraceWriter used by the serializer when writing trace messages.
Declaration
public virtual ITraceWriter TraceWriter { get; set; }
Property Value
|
Improve this Doc
View Source
Gets or sets how a type name assembly is written and resolved by the serializer.
Declaration
public virtual FormatterAssemblyStyle TypeNameAssemblyFormat { get; set; }
Property Value
Type
Description
System.Runtime.Serialization.Formatters.FormatterAssemblyStyle
The type name assembly format.
|
Improve this Doc
View Source
TypeNameHandling
Gets or sets how type name writing and reading is handled by the serializer.
Declaration
public virtual TypeNameHandling TypeNameHandling { get; set; }
Property Value
Remarks
Methods
|
Improve this Doc
View Source
AddAllAvailableConverters()
Declaration
public void AddAllAvailableConverters()
|
Improve this Doc
View Source
AddAllAvailableObjectConverters()
Declaration
public void AddAllAvailableObjectConverters()
|
Improve this Doc
View Source
ApplySerializerSettings(JsonSerializer, JsonSerializerSettings)
Declaration
protected static void ApplySerializerSettings(JsonSerializer serializer, JsonSerializerSettings settings)
Parameters
|
Improve this Doc
View Source
Create()
Declaration
public static JsonSerializer Create()
Returns
|
Improve this Doc
View Source
Create(JsonSerializerSettings)
Declaration
public static JsonSerializer Create(JsonSerializerSettings settings)
Parameters
Returns
|
Improve this Doc
View Source
CreateDefault()
Declaration
public static JsonSerializer CreateDefault()
Returns
|
Improve this Doc
View Source
CreateDefault(JsonSerializerSettings)
Declaration
public static JsonSerializer CreateDefault(JsonSerializerSettings settings)
Parameters
Returns
|
Improve this Doc
View Source
Deserialize(JsonReader)
Deserializes the JSON structure contained by the specified JsonReader .
Declaration
public object Deserialize(JsonReader reader)
Parameters
Type
Name
Description
JsonReader
reader
The JsonReader that contains the JSON structure to deserialize.
Returns
Type
Description
System.Object
The System.Object being deserialized.
|
Improve this Doc
View Source
Deserialize(JsonReader, Type)
Deserializes the JSON structure contained by the specified JsonReader
into an instance of the specified type.
Declaration
public object Deserialize(JsonReader reader, Type objectType)
Parameters
Type
Name
Description
JsonReader
reader
The JsonReader containing the object.
System.Type
objectType
The System.Type of object being deserialized.
Returns
Type
Description
System.Object
The instance of objectType
being deserialized.
|
Improve this Doc
View Source
Deserialize(TextReader, Type)
Deserializes the JSON structure contained by the specified System.IO.StringReader
into an instance of the specified type.
Declaration
public object Deserialize(TextReader reader, Type objectType)
Parameters
Type
Name
Description
System.IO.TextReader
reader
The System.IO.TextReader containing the object.
System.Type
objectType
The System.Type of object being deserialized.
Returns
Type
Description
System.Object
The instance of objectType
being deserialized.
|
Improve this Doc
View Source
Deserialize<T>(JsonReader)
Deserializes the JSON structure contained by the specified JsonReader
into an instance of the specified type.
Declaration
public T Deserialize<T>(JsonReader reader)
Parameters
Returns
Type
Description
T
The instance of T
being deserialized.
Type Parameters
Name
Description
T
The type of the object to deserialize.
|
Improve this Doc
View Source
DeserializeInternal(JsonReader, Type)
Declaration
protected virtual object DeserializeInternal(JsonReader reader, Type objectType)
Parameters
Type
Name
Description
JsonReader
reader
System.Type
objectType
Returns
Type
Description
System.Object
|
Improve this Doc
View Source
DeserializeInto(JsonReader, Object)
Deserializes the JSON structure contained by the specified JsonReader
into an instance of the specified type.
Declaration
public object DeserializeInto(JsonReader reader, object target)
Parameters
Type
Name
Description
JsonReader
reader
The JsonReader containing the object.
System.Object
target
The target object to populate values onto.
Returns
Type
Description
System.Object
|
Improve this Doc
View Source
DeserializeInto(TextReader, Object)
Deserializes the JSON structure contained by the specified System.IO.StringReader
into an instance of the specified type.
Declaration
public object DeserializeInto(TextReader reader, object target)
Parameters
Type
Name
Description
System.IO.TextReader
reader
The System.IO.TextReader containing the object.
System.Object
target
The target object to populate values onto.
Returns
Type
Description
System.Object
|
Improve this Doc
View Source
DeserializeIntoInternal(JsonReader, Object)
Declaration
protected virtual object DeserializeIntoInternal(JsonReader reader, object target)
Parameters
Type
Name
Description
JsonReader
reader
System.Object
target
Returns
Type
Description
System.Object
|
Improve this Doc
View Source
GetAllAvailableConverters()
Declaration
public static JsonConverter[] GetAllAvailableConverters()
Returns
|
Improve this Doc
View Source
GetMatchingConverter(IList<JsonConverter>, Type)
Declaration
public static JsonConverter GetMatchingConverter(IList<JsonConverter> converters, Type objectType)
Parameters
Type
Name
Description
System.Collections.Generic.IList <JsonConverter >
converters
System.Type
objectType
Returns
|
Improve this Doc
View Source
GetMatchingConverter(Type)
Declaration
public JsonConverter GetMatchingConverter(Type type)
Parameters
Type
Name
Description
System.Type
type
Returns
|
Improve this Doc
View Source
GetReferenceResolver()
Declaration
protected IReferenceResolver GetReferenceResolver()
Returns
|
Improve this Doc
View Source
IsCheckAdditionalContentSet()
Declaration
public bool IsCheckAdditionalContentSet()
Returns
Type
Description
System.Boolean
|
Improve this Doc
View Source
OnError(ErrorEventArgs)
Declaration
public void OnError(ErrorEventArgs e)
Parameters
|
Improve this Doc
View Source
Populate(JsonReader, Object)
Populates the JSON values onto the target object.
Declaration
public void Populate(JsonReader reader, object target)
Parameters
Type
Name
Description
JsonReader
reader
The JsonReader that contains the JSON structure to reader values from.
System.Object
target
The target object to populate values onto.
|
Improve this Doc
View Source
Populate(TextReader, Object)
Populates the JSON values onto the target object.
Declaration
public void Populate(TextReader reader, object target)
Parameters
Type
Name
Description
System.IO.TextReader
reader
The System.IO.TextReader that contains the JSON structure to reader values from.
System.Object
target
The target object to populate values onto.
|
Improve this Doc
View Source
PopulateInternal(JsonReader, Object)
Declaration
protected virtual void PopulateInternal(JsonReader reader, object target)
Parameters
Type
Name
Description
JsonReader
reader
System.Object
target
|
Improve this Doc
View Source
Serialize(JsonWriter, Object)
Serializes the specified System.Object and writes the JSON structure
to a Stream
using the specified JsonWriter .
Declaration
public void Serialize(JsonWriter jsonWriter, object value)
Parameters
Type
Name
Description
JsonWriter
jsonWriter
The JsonWriter used to write the JSON structure.
System.Object
value
The System.Object to serialize.
|
Improve this Doc
View Source
Serialize(JsonWriter, Object, Type)
Serializes the specified System.Object and writes the JSON structure
to a Stream
using the specified System.IO.TextWriter .
Declaration
public void Serialize(JsonWriter jsonWriter, object value, Type objectType)
Parameters
Type
Name
Description
JsonWriter
jsonWriter
The JsonWriter used to write the JSON structure.
System.Object
value
The System.Object to serialize.
System.Type
objectType
The type of the value being serialized.
This parameter is used when TypeNameHandling is Auto to write out the type name if the type of the value does not match.
Specifing the type is optional.
|
Improve this Doc
View Source
Serialize(TextWriter, Object)
Serializes the specified System.Object and writes the JSON structure
to a Stream
using the specified System.IO.TextWriter .
Declaration
public void Serialize(TextWriter textWriter, object value)
Parameters
Type
Name
Description
System.IO.TextWriter
textWriter
The System.IO.TextWriter used to write the JSON structure.
System.Object
value
The System.Object to serialize.
|
Improve this Doc
View Source
Serialize(TextWriter, Object, Type)
Serializes the specified System.Object and writes the JSON structure
to a Stream
using the specified System.IO.TextWriter .
Declaration
public void Serialize(TextWriter textWriter, object value, Type objectType)
Parameters
Type
Name
Description
System.IO.TextWriter
textWriter
The System.IO.TextWriter used to write the JSON structure.
System.Object
value
The System.Object to serialize.
System.Type
objectType
The type of the value being serialized.
This parameter is used when TypeNameHandling is Auto to write out the type name if the type of the value does not match.
Specifing the type is optional.
|
Improve this Doc
View Source
SerializeInternal(JsonWriter, Object, Type)
Declaration
protected virtual void SerializeInternal(JsonWriter jsonWriter, object value, Type objectType)
Parameters
Type
Name
Description
JsonWriter
jsonWriter
System.Object
value
System.Type
objectType
Events
|
Improve this Doc
View Source
Error
Occurs when the JsonSerializer errors during serialization and deserialization.
Declaration
public virtual event EventHandler<ErrorEventArgs> Error
Event Type
Please enable JavaScript to view the comments powered by Disqus.