Decoder typedef
Decoding options for QS.decode.
This mirrors the behavior of the reference qs
library and provides a few
guard rails against untrusted input (parameter count, nesting depth, list
index limits). The defaults aim to be safe and predictable while matching
the semantics used across the ports in this repository.
Highlights
- Dot notation: set
allowDots
to treata.b=c
like{a: {b: "c"}}
. If you explicitly request dot decoding in keys viadecodeDotInKeys
,allowDots
is implied and will be treated astrue
unless you explicitly setallowDots: false
— which is an invalid combination and will throw at construction time. - Charset handling:
charset
selects UTF‑8 or Latin‑1 decoding. WhencharsetSentinel
istrue
, a leadingutf8=✓
token (in either UTF‑8 or Latin‑1 form) can overridecharset
as a compatibility escape hatch. - Limits:
parameterLimit
,depth
, andlistLimit
are DoS guards. If you want hard failures instead of soft limiting, enablethrowOnLimitExceeded
and/orstrictDepth
. - Duplicates: use
duplicates
to pick a strategy when the same key is present multiple times in the input.
See also: the options types in other ports for parity, and the individual doc comments below for precise semantics. Preferred signature for a custom scalar decoder used by DecodeOptions.
Implementations may choose to ignore charset
or kind
, but both are
provided to enable key-aware decoding when desired.
Implementation
/// Preferred signature for a custom scalar decoder used by [DecodeOptions].
///
/// Implementations may choose to ignore [charset] or [kind], but both are
/// provided to enable key-aware decoding when desired.
typedef Decoder = dynamic Function(
String? value, {
Encoding? charset,
DecodeKind? kind,
});