Decoder typedef

Decoder = dynamic Function(String? value, {Encoding? charset, DecodeKind? kind})

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 treat a.b=c like {a: {b: "c"}}. If you explicitly request dot decoding in keys via decodeDotInKeys, allowDots is implied and will be treated as true unless you explicitly set allowDots: false — which is an invalid combination and will throw at construction time.
  • Charset handling: charset selects UTF‑8 or Latin‑1 decoding. When charsetSentinel is true, a leading utf8=✓ token (in either UTF‑8 or Latin‑1 form) can override charset as a compatibility escape hatch.
  • Limits: parameterLimit, depth, and listLimit are DoS guards. If you want hard failures instead of soft limiting, enable throwOnLimitExceeded and/or strictDepth.
  • 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,
});