From 1fc00d2ec7db583b18cf30b1205a3df398a295cf Mon Sep 17 00:00:00 2001 From: Sebastian Rodriguez Date: Mon, 2 Oct 2017 22:19:27 +0100 Subject: [PATCH] add JsonSerializerSettings defaults documentation. See issue #1245 --- Src/Newtonsoft.Json/JsonSerializerSettings.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Src/Newtonsoft.Json/JsonSerializerSettings.cs b/Src/Newtonsoft.Json/JsonSerializerSettings.cs index 6a6faace..cb03b914 100644 --- a/Src/Newtonsoft.Json/JsonSerializerSettings.cs +++ b/Src/Newtonsoft.Json/JsonSerializerSettings.cs @@ -88,6 +88,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how reference loops (e.g. a class referencing itself) are handled. + /// By default errors if a reference loop is encountered. /// /// Reference loop handling. public ReferenceLoopHandling ReferenceLoopHandling @@ -98,6 +99,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how missing members (e.g. JSON contains a property that isn't a member on the object) are handled during deserialization. + /// By default ignores missing members. /// /// Missing member handling. public MissingMemberHandling MissingMemberHandling @@ -108,6 +110,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how objects are created during deserialization. + /// By default attempts to set JSON values onto existing objects and add JSON values to existing collections during deserialization. /// /// The object creation handling. public ObjectCreationHandling ObjectCreationHandling @@ -118,6 +121,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how null values are handled during serialization and deserialization. + /// By default writes null values to JSON when serializing and sets null values to fields/properties when deserializing. /// /// Null value handling. public NullValueHandling NullValueHandling @@ -128,6 +132,8 @@ namespace Newtonsoft.Json /// /// Gets or sets how default values are handled during serialization and deserialization. + /// By default writes a field/property value to JSON when serializing if the value is the same as the field/property's default value. + /// The deserializer will continue setting a field/property if the JSON value is the same as the default value. /// /// The default value handling. public DefaultValueHandling DefaultValueHandling @@ -144,6 +150,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how object references are preserved by the serializer. + /// By default does not preserves references when serializing types. /// /// The preserve references handling. public PreserveReferencesHandling PreserveReferencesHandling @@ -154,6 +161,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how type name writing and reading is handled by the serializer. + /// By default does not read or write type names during deserialization. /// /// /// should be used with caution when your application deserializes JSON from an external source. @@ -169,6 +177,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how metadata properties are used during deserialization. + /// By default reads the metadata properties located at the start of a JSON object. /// /// The metadata properties handling. public MetadataPropertyHandling MetadataPropertyHandling @@ -179,6 +188,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how a type name assembly is written and resolved by the serializer. + /// By default writes the partial assembly name with the type. /// /// The type name assembly format. [Obsolete("TypeNameAssemblyFormat is obsolete. Use TypeNameAssemblyFormatHandling instead.")] @@ -190,6 +200,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how a type name assembly is written and resolved by the serializer. + /// By default the assembly used during deserialization need not match exactly the assembly used during serialization. /// /// The type name assembly format. public TypeNameAssemblyFormatHandling TypeNameAssemblyFormatHandling @@ -200,6 +211,11 @@ namespace Newtonsoft.Json /// /// Gets or sets how constructors are used during deserialization. + /// By default first looks for a constructor marked with the JsonConstructorAttribute, then look for a public default constructor + /// (a constructor that doesn't take any arguments), then check if the class has a single public constructor with arguments + /// and finally check for a non-public default constructor. + /// If the class has multiple public constructors with arguments an error will be thrown. + /// This can be fixed by marking one of the constructors with the JsonConstructorAttribute. /// /// The constructor handling. public ConstructorHandling ConstructorHandling @@ -302,6 +318,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how and values are formatted when writing JSON text, /// and the expected date format when reading JSON text. + /// By default uses the format "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK" /// public string DateFormatString { @@ -333,6 +350,7 @@ namespace Newtonsoft.Json /// /// Indicates how JSON text output is formatted. + /// By default no special formatting is applied. /// public Formatting Formatting { @@ -342,6 +360,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how dates are written to JSON text. + /// By default writes dates in ISO 8601 format. /// public DateFormatHandling DateFormatHandling { @@ -351,6 +370,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how time zones are handled during serialization and deserialization. + /// By default time zone information is preserved when converting. /// public DateTimeZoneHandling DateTimeZoneHandling { @@ -360,6 +380,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how date formatted strings, e.g. "\/Date(1198908717056)\/" and "2012-03-21T05:40Z", are parsed when reading JSON. + /// By default dates are parsed to /// public DateParseHandling DateParseHandling { @@ -371,6 +392,7 @@ namespace Newtonsoft.Json /// Gets or sets how special floating point numbers, e.g. , /// and , /// are written as JSON. + /// By default writes special floating point values as strings in JSON, e.g. "NaN", "Infinity", "-Infinity". /// public FloatFormatHandling FloatFormatHandling { @@ -380,6 +402,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how floating point numbers, e.g. 1.0 and 9.9, are parsed when reading JSON text. + /// By default floating point numbers are parsed to . /// public FloatParseHandling FloatParseHandling { @@ -389,6 +412,7 @@ namespace Newtonsoft.Json /// /// Gets or sets how strings are escaped when writing JSON text. + /// By default only control characters (e.g. newline) are escaped. /// public StringEscapeHandling StringEscapeHandling { @@ -407,6 +431,7 @@ namespace Newtonsoft.Json /// /// Gets a value indicating whether there will be a check for additional content after deserializing an object. + /// By default set to false. /// /// /// true if there will be a check for additional content after deserializing an object; otherwise, false.