-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration: Serializer
You can pass a CDIFSerializerOptions object to CDIF.serialize() and CDIF.serializeFile() to customize the behavior of the serializer. All values are optional, and will fall back to a default value if they are omitted or undefined. The available options in CDIFSerializerOptions are as follows:
strict?: boolean;Whether the serializer should operate in "strict mode." In general, strict mode throws an error if a value cannot be serialized, while non-strict mode omits the value or replaces it with null. The following table lists all specific differences:
| Case | Strict mode | Non-strict mode |
|---|---|---|
Value is NaN
|
CDIFTypeError thrown |
Value replaced with null
|
| Value is a symbol |
CDIFTypeError thrown |
Value omitted |
| Value is a function |
CDIFTypeError thrown |
Value omitted |
| Value in collection omitted |
CDIFError thrown |
Value replaced with null
|
Default value: true
indent?: string | null;String to use to indent a level in the serialized cDIF text (ex. "\t" or " "), or null to output as one line. (If minify is true, this option will be ignored.)
Default value: null
minify?: boolean;Whether the output should be one line with no optional whitespace. (If true, the indent option will be ignored.)
Default value: false
structureEntrySeparator?: "," | ";";Separator between object or collection entries in the serialized cDIF text.
Default value: ","
addFinalStructureEntrySeparator?: boolean;Whether a separator should be added after the last entry in an object or collection.
Default value: if structureEntrySeparator is ";" then true, else false
preprocessors?: ReadonlyArray<CDIFSerializerPreprocessorFunction>;Array of preprocessor functions, in order of precedence. Preprocessor functions are called for each value before serialization. They can be used to customize the behavior of the serializer (ex. to add type names to values). See the documentation on preprocessors for more information.
Default value: []