Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class Newtonsoft.​Json.​JsonSerializer
Assembly: Newtonsoft.Json
Inheritance: object → JsonSerializer
Serializes and deserializes objects into and from the JSON format. The <see cref="T:Newtonsoft.Json.JsonSerializer" /> enables you to control how objects are encoded into JSON.
Properties
public
IReferenceResolver
ReferenceResolver
Gets or sets the <see cref="T:Newtonsoft.Json.Serialization.IReferenceResolver" /> used by the serializer when resolving references.
public
SerializationBinder
Binder
Gets or sets the <see cref="P:Newtonsoft.Json.JsonSerializer.SerializationBinder" /> used by the serializer when resolving type names.
public
ISerializationBinder
SerializationBinder
Gets or sets the <see cref="T:Newtonsoft.Json.Serialization.ISerializationBinder" /> used by the serializer when resolving type names.
public
ITraceWriter
TraceWriter
Gets or sets the <see cref="T:Newtonsoft.Json.Serialization.ITraceWriter" /> used by the serializer when writing trace messages.
EqualityComparer
Gets or sets the equality comparer used by the serializer when comparing references.
public
TypeNameHandling
TypeNameHandling
Gets or sets how type name writing and reading is handled by the serializer.
Remarks <see cref="P:Newtonsoft.Json.JsonSerializer.TypeNameHandling" /> should be used with caution when your application deserializes JSON from an external source.
Incoming types should be validated with a custom <see cref="P:Newtonsoft.Json.JsonSerializer.SerializationBinder" />
when deserializing with a value other than <see cref="F:Newtonsoft.Json.TypeNameHandling.None" /> .
TypeNameAssemblyFormat
Gets or sets how a type name assembly is written and resolved by the serializer.
TypeNameAssemblyFormatHandling
Gets or sets how a type name assembly is written and resolved by the serializer.
public
PreserveReferencesHandling
PreserveReferencesHandling
Gets or sets how object references are preserved by the serializer.
public
ReferenceLoopHandling
ReferenceLoopHandling
Gets or sets how reference loops (e.g. a class referencing itself) is handled.
public
MissingMemberHandling
MissingMemberHandling
Gets or sets how missing members (e.g. JSON contains a property that isn't a member on the object) are handled during deserialization.
public
NullValueHandling
NullValueHandling
Gets or sets how null values are handled during serialization and deserialization.
public
DefaultValueHandling
DefaultValueHandling
Gets or sets how default values are handled during serialization and deserialization.
public
ObjectCreationHandling
ObjectCreationHandling
Gets or sets how objects are created during deserialization.
public
ConstructorHandling
ConstructorHandling
Gets or sets how constructors are used during deserialization.
public
MetadataPropertyHandling
MetadataPropertyHandling
Gets or sets how metadata properties are used during deserialization.
public
JsonConverterCollection
Converters
Gets a collection <see cref="T:Newtonsoft.Json.JsonConverter" /> that will be used during serialization.
public
IContractResolver
ContractResolver
Gets or sets the contract resolver used by the serializer when
serializing .NET objects to JSON and vice versa.
public
System.​Runtime.​Serialization.​StreamingContext
Context
Gets or sets the <see cref="T:System.Runtime.Serialization.StreamingContext" /> used by the serializer when invoking serialization callback methods.
public
Formatting
Formatting
Indicates how JSON text output is formatted.
public
DateFormatHandling
DateFormatHandling
Gets or sets how dates are written to JSON text.
public
DateTimeZoneHandling
DateTimeZoneHandling
Gets or sets how <see cref="T:System.DateTime" /> time zones are handled during serialization and deserialization.
public
DateParseHandling
DateParseHandling
Gets or sets how date formatted strings, e.g. <c>"\/Date(1198908717056)\/"</c> and <c>"2012-03-21T05:40Z"</c> , are parsed when reading JSON.
public
FloatParseHandling
FloatParseHandling
Gets or sets how floating point numbers, e.g. 1.0 and 9.9, are parsed when reading JSON text.
public
FloatFormatHandling
FloatFormatHandling
Gets or sets how special floating point numbers, e.g. <see cref="F:System.Double.NaN" /> ,
<see cref="F:System.Double.PositiveInfinity" /> and <see cref="F:System.Double.NegativeInfinity" /> ,
are written as JSON text.
public
StringEscapeHandling
StringEscapeHandling
Gets or sets how strings are escaped when writing JSON text.
public
string
DateFormatString
Gets or sets how <see cref="T:System.DateTime" /> and <see cref="T:System.DateTimeOffset" /> values are formatted when writing JSON text,
and the expected date format when reading JSON text.
Gets or sets the culture used when reading JSON. Defaults to <see cref="P:System.Globalization.CultureInfo.InvariantCulture" /> .
public
int?
MaxDepth
Gets or sets the maximum depth allowed when reading JSON. Reading past this depth will throw a <see cref="T:Newtonsoft.Json.JsonReaderException" /> .
public
bool
CheckAdditionalContent
Gets a value indicating whether there will be a check for additional JSON content after deserializing an object.
Methods
public static
JsonSerializer
Create​()
Creates a new <see cref="T:Newtonsoft.Json.JsonSerializer" /> instance.
The <see cref="T:Newtonsoft.Json.JsonSerializer" /> will not use default settings
from <see cref="P:Newtonsoft.Json.JsonConvert.DefaultSettings" /> .
Returns A new <see cref="T:Newtonsoft.Json.JsonSerializer" /> instance.
The <see cref="T:Newtonsoft.Json.JsonSerializer" /> will not use default settings
from <see cref="P:Newtonsoft.Json.JsonConvert.DefaultSettings" /> .
public static
JsonSerializer
Create​(JsonSerializerSettings settings)
Creates a new <see cref="T:Newtonsoft.Json.JsonSerializer" /> instance using the specified <see cref="T:Newtonsoft.Json.JsonSerializerSettings" /> .
The <see cref="T:Newtonsoft.Json.JsonSerializer" /> will not use default settings
from <see cref="P:Newtonsoft.Json.JsonConvert.DefaultSettings" /> .
Returns A new <see cref="T:Newtonsoft.Json.JsonSerializer" /> instance using the specified <see cref="T:Newtonsoft.Json.JsonSerializerSettings" /> .
The <see cref="T:Newtonsoft.Json.JsonSerializer" /> will not use default settings
from <see cref="P:Newtonsoft.Json.JsonConvert.DefaultSettings" /> .
settings
The settings to be applied to the <see cref="T:Newtonsoft.Json.JsonSerializer" /> .
public static
JsonSerializer
CreateDefault​()
Creates a new <see cref="T:Newtonsoft.Json.JsonSerializer" /> instance.
The <see cref="T:Newtonsoft.Json.JsonSerializer" /> will use default settings
from <see cref="P:Newtonsoft.Json.JsonConvert.DefaultSettings" /> .
Returns A new <see cref="T:Newtonsoft.Json.JsonSerializer" /> instance.
The <see cref="T:Newtonsoft.Json.JsonSerializer" /> will use default settings
from <see cref="P:Newtonsoft.Json.JsonConvert.DefaultSettings" /> .
public static
JsonSerializer
CreateDefault​(JsonSerializerSettings settings)
Creates a new <see cref="T:Newtonsoft.Json.JsonSerializer" /> instance using the specified <see cref="T:Newtonsoft.Json.JsonSerializerSettings" /> .
The <see cref="T:Newtonsoft.Json.JsonSerializer" /> will use default settings
from <see cref="P:Newtonsoft.Json.JsonConvert.DefaultSettings" /> as well as the specified <see cref="T:Newtonsoft.Json.JsonSerializerSettings" /> .
Returns A new <see cref="T:Newtonsoft.Json.JsonSerializer" /> instance using the specified <see cref="T:Newtonsoft.Json.JsonSerializerSettings" /> .
The <see cref="T:Newtonsoft.Json.JsonSerializer" /> will use default settings
from <see cref="P:Newtonsoft.Json.JsonConvert.DefaultSettings" /> as well as the specified <see cref="T:Newtonsoft.Json.JsonSerializerSettings" /> .
settings
The settings to be applied to the <see cref="T:Newtonsoft.Json.JsonSerializer" /> .
public
void
Populate​(System.​IO.​TextReader reader,
object target)
Populates the JSON values onto the target object.
reader
The <see cref="T:System.IO.TextReader" /> that contains the JSON structure to reader values from.
target
The target object to populate values onto.
public
void
Populate​(JsonReader reader,
object target)
Populates the JSON values onto the target object.
reader
The <see cref="T:Newtonsoft.Json.JsonReader" /> that contains the JSON structure to reader values from.
target
The target object to populate values onto.
public
object
Deserialize​(JsonReader reader)
Deserializes the JSON structure contained by the specified <see cref="T:Newtonsoft.Json.JsonReader" /> .
Returns The <see cref="T:System.Object" /> being deserialized.
reader
The <see cref="T:Newtonsoft.Json.JsonReader" /> that contains the JSON structure to deserialize.
public
object
Deserialize​(System.​IO.​TextReader reader,
System.​Type objectType)
Deserializes the JSON structure contained by the specified <see cref="T:System.IO.StringReader" />
into an instance of the specified type.
Returns The instance of <paramref name="objectType" /> being deserialized.
reader
The <see cref="T:System.IO.TextReader" /> containing the object.
objectType
The <see cref="T:System.Type" /> of object being deserialized.
public
T
Deserialize​(JsonReader reader)
Deserializes the JSON structure contained by the specified <see cref="T:Newtonsoft.Json.JsonReader" />
into an instance of the specified type.
Returns The instance of <typeparamref name="T" /> being deserialized.
reader
The <see cref="T:Newtonsoft.Json.JsonReader" /> containing the object.
public
object
Deserialize​(JsonReader reader,
System.​Type objectType)
Deserializes the JSON structure contained by the specified <see cref="T:Newtonsoft.Json.JsonReader" />
into an instance of the specified type.
Returns The instance of <paramref name="objectType" /> being deserialized.
reader
The <see cref="T:Newtonsoft.Json.JsonReader" /> containing the object.
objectType
The <see cref="T:System.Type" /> of object being deserialized.
public
void
Serialize​(System.​IO.​TextWriter textWriter,
object value)
Serializes the specified <see cref="T:System.Object" /> and writes the JSON structure
using the specified <see cref="T:System.IO.TextWriter" /> .
textWriter
The <see cref="T:System.IO.TextWriter" /> used to write the JSON structure.
value
The <see cref="T:System.Object" /> to serialize.
public
void
Serialize​(JsonWriter jsonWriter,
object value,
System.​Type objectType)
Serializes the specified <see cref="T:System.Object" /> and writes the JSON structure
using the specified <see cref="T:Newtonsoft.Json.JsonWriter" /> .
jsonWriter
The <see cref="T:Newtonsoft.Json.JsonWriter" /> used to write the JSON structure.
value
The <see cref="T:System.Object" /> to serialize.
objectType
The type of the value being serialized.
This parameter is used when <see cref="P:Newtonsoft.Json.JsonSerializer.TypeNameHandling" /> is <see cref="F:Newtonsoft.Json.TypeNameHandling.Auto" /> to write out the type name if the type of the value does not match.
Specifying the type is optional.
public
void
Serialize​(System.​IO.​TextWriter textWriter,
object value,
System.​Type objectType)
Serializes the specified <see cref="T:System.Object" /> and writes the JSON structure
using the specified <see cref="T:System.IO.TextWriter" /> .
textWriter
The <see cref="T:System.IO.TextWriter" /> used to write the JSON structure.
value
The <see cref="T:System.Object" /> to serialize.
objectType
The type of the value being serialized.
This parameter is used when <see cref="P:Newtonsoft.Json.JsonSerializer.TypeNameHandling" /> is Auto to write out the type name if the type of the value does not match.
Specifying the type is optional.
public
void
Serialize​(JsonWriter jsonWriter,
object value)
Serializes the specified <see cref="T:System.Object" /> and writes the JSON structure
using the specified <see cref="T:Newtonsoft.Json.JsonWriter" /> .
jsonWriter
The <see cref="T:Newtonsoft.Json.JsonWriter" /> used to write the JSON structure.
value
The <see cref="T:System.Object" /> to serialize.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object