ToonOutputFormatter supports request-scoped response encode overrides through HTTP request headers.
This allows a caller to change how one response is encoded without mutating the application-wide ToonServiceOptions.
Use:
X-Toon-Option-<OptionName>: <value>
Example:
GET /products
Accept: application/toon
X-Toon-Option-IgnoreNullOrEmpty: true
X-Toon-Option-ExcludeEmptyArrays: true
X-Toon-Option-ObjectArrayLayout: Columnar
X-Toon-Option-ByteArrayFormat: NumericArray
X-Toon-Option-KeyFolding: Off
X-Toon-Option-Delimiter: COMMA
Any writable public property on ToonEncodeOptions can be overridden per request, including:
IndentDelimiterKeyFoldingFlattenDepthObjectArrayLayoutByteArrayFormatIgnoreNullOrEmptyExcludeEmptyArraysByteArrayFormat is useful when the API should keep compact Base64 output by default but allow a caller to opt into numeric arrays for one response:
GET /files/42
Accept: application/toon
X-Toon-Option-ByteArrayFormat: NumericArray
options.Encode.ByteArrayFormat = ToonByteArrayFormat.Base64String; is the default, matching the DevOp.Toon runtime behavior for byte[], List<byte>, and IEnumerable<byte>This is especially useful when: