/// <summary> /// Configuration for Jil serialization options. /// /// Available options: /// prettyPrint - whether or not to include whitespace and newlines for ease of reading /// excludeNulls - whether or not to write object members whose value is null /// jsonp - whether or not the serialized json should be valid for use with JSONP /// dateFormat - the style in which to serialize DateTimes and TimeSpans /// includeInherited - whether or not to serialize members declared by an objects base types /// allowHashFunction - whether or not Jil should try to use hashes instead of strings when deserializing object members, malicious content may be able to force member collisions if this is enabled /// </summary> public Options(bool prettyPrint = false, bool excludeNulls = false, bool jsonp = false, DateTimeFormat dateFormat = DateTimeFormat.NewtonsoftStyleMillisecondsSinceUnixEpoch, bool includeInherited = false, UnspecifiedDateTimeKindBehavior unspecifiedDateTimeKindBehavior = UnspecifiedDateTimeKindBehavior.IsLocal) { ShouldPrettyPrint = prettyPrint; ShouldExcludeNulls = excludeNulls; IsJSONP = jsonp; UseDateTimeFormat = dateFormat; ShouldIncludeInherited = includeInherited; UseUnspecifiedDateTimeKindBehavior = unspecifiedDateTimeKindBehavior; }
/// <summary> /// Configuration for Jil serialization options. /// /// Available options: /// prettyPrint - whether or not to include whitespace and newlines for ease of reading /// excludeNulls - whether or not to write object members whose value is null /// jsonp - whether or not the serialized json should be valid for use with JSONP /// dateFormat - the style in which to serialize DateTimes and TimeSpans /// includeInherited - whether or not to serialize members declared by an objects base types /// unspecifiedDateTimeKindBehavior - how to treat DateTime's with a DateTimeKind of Unspecified (Jil converts all DateTimes to Utc for serialization, use DateTimeOffset to preserve time zone information) /// </summary> public Options(bool prettyPrint = false, bool excludeNulls = false, bool jsonp = false, DateTimeFormat dateFormat = DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch, bool includeInherited = false, UnspecifiedDateTimeKindBehavior unspecifiedDateTimeKindBehavior = UnspecifiedDateTimeKindBehavior.IsLocal) { ShouldPrettyPrint = prettyPrint; ShouldExcludeNulls = excludeNulls; IsJSONP = jsonp; #pragma warning disable 618 // upgrade from the obsolete DateTimeFormat enumeration; warning disabled to allow it, but all other references // should be expunged if (dateFormat == DateTimeFormat.NewtonsoftStyleMillisecondsSinceUnixEpoch) { dateFormat = DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch; } #pragma warning restore 618 UseDateTimeFormat = dateFormat; ShouldIncludeInherited = includeInherited; UseUnspecifiedDateTimeKindBehavior = unspecifiedDateTimeKindBehavior; }
/// <summary> /// Configuration for Jil serialization options. /// /// Available options: /// prettyPrint - whether or not to include whitespace and newlines for ease of reading /// excludeNulls - whether or not to write object members whose value is null /// jsonp - whether or not the serialized json should be valid for use with JSONP /// dateFormat - the style in which to serialize DateTimes and TimeSpans /// includeInherited - whether or not to serialize members declared by an objects base types /// unspecifiedDateTimeKindBehavior - how to treat DateTime's with a DateTimeKind of Unspecified (Jil converts all DateTimes to Utc for serialization, use DateTimeOffset to preserve time zone information) /// serializationNameFormat - how to serialize names of properties/objects unless specified explicitly by an attribute /// </summary> public Options(bool prettyPrint = false, bool excludeNulls = false, bool jsonp = false, DateTimeFormat dateFormat = DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch, bool includeInherited = false, UnspecifiedDateTimeKindBehavior unspecifiedDateTimeKindBehavior = UnspecifiedDateTimeKindBehavior.IsLocal, SerializationNameFormat serializationNameFormat = SerializationNameFormat.Verbatim) { ShouldPrettyPrint = prettyPrint; ShouldExcludeNulls = excludeNulls; IsJSONP = jsonp; #pragma warning disable 618 // upgrade from the obsolete DateTimeFormat enumeration; warning disabled to allow it, but all other references // should be expunged if (dateFormat == DateTimeFormat.NewtonsoftStyleMillisecondsSinceUnixEpoch) { dateFormat = DateTimeFormat.MicrosoftStyleMillisecondsSinceUnixEpoch; } #pragma warning restore 618 UseDateTimeFormat = dateFormat; ShouldIncludeInherited = includeInherited; UseUnspecifiedDateTimeKindBehavior = unspecifiedDateTimeKindBehavior; SerializationNameFormat = serializationNameFormat; }
/// <summary> /// For compatibility with earlier Jil versions. /// /// Configuration for Jil serialization options. /// /// Available options: /// prettyPrint - whether or not to include whitespace and newlines for ease of reading /// excludeNulls - whether or not to write object members whose value is null /// jsonp - whether or not the serialized json should be valid for use with JSONP /// dateFormat - the style in which to serialize DateTimes and TimeSpans /// includeInherited - whether or not to serialize members declared by an objects base types /// unspecifiedDateTimeKindBehavior - how to treat DateTime's with a DateTimeKind of Unspecified (Jil converts all DateTimes to Utc for serialization, use DateTimeOffset to preserve time zone information) /// </summary> public Options(bool prettyPrint, bool excludeNulls, bool jsonp, DateTimeFormat dateFormat, bool includeInherited, UnspecifiedDateTimeKindBehavior unspecifiedDateTimeKindBehavior) : this(prettyPrint, excludeNulls, jsonp, dateFormat, includeInherited, unspecifiedDateTimeKindBehavior, SerializationNameFormat.Verbatim) { }