Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml Inheritance: System.EnumSyntax
Summary
Specifies the predefined sets of options that an XmlSerializerOptions instance can be created with.Usage
XmlSerializerDefaults names a starting set of option values. Pass a value to the XmlSerializerOptions constructor, then set whatever else you need. It is the counterpart of JsonSerializerDefaults.
Examples
The following example shows what the strict defaults add to the general ones.Compare the general and the strict defaults when reading
The strict defaults change reading, apart from refusing to write anull that a nullable annotation forbids. The following example reads a document with a repeated element, one with a comment, and one with an unknown element, first with the general defaults and then with the strict ones.
Considerations
Webis smaller thanJsonSerializerDefaults.Web. It doesn’t make name matching case-insensitive, and it doesn’t change how numbers are read. SetPropertyNameCaseInsensitiveyourself if you need it.- With
Web, the camelCase policy also applies to the document element, so a type namedInvoiceLineis written as<invoiceLine>. Strictchanges what is written in one case only: withRespectNullableAnnotationson, a member annotated non-nullable that holdsnullthrows when it is written. It doesn’t set any of the size limits. For XML from an untrusted source, also setMaxDocumentByteCount. See Security.- The value is only a starting point. It isn’t stored on the options, so there’s no way to ask an instance which set it was created from.
Values
Related APIs
- CloudNimble.Text.Xml.XmlSerializerOptions
- CloudNimble.Text.Xml.XmlSerializer
- CloudNimble.Text.Xml.XmlNamingPolicy
- CloudNimble.Text.Xml.XmlCommentHandling
- CloudNimble.Text.Xml.Serialization.XmlUnmappedMemberHandling