Per-entry lenient dictionary decoding
@LenientDecodable structs can now decode dictionary properties leniently — one broken entry no longer takes down the other 99.
New
@NilOnFailure(or the implicit default) on[K: V?]— value padding: a broken value becomesnilat its key, the rest of the dictionary survives.[K: V?]?decodes absent/unusable dictionaries asnilinstead of[:].@DropOnFailureon[K: V]— broken entries are removed, survivors keep their keys.LenientDictionaryKey— the string→key contract (a decode-only, failure-tolerant analogue ofCodingKeyRepresentable, back-deployed to iOS 13).StringandIntconform out of the box; enum keys opt in with one line:Unknown enum keys drop their entry instead of failing the whole decode.extension Status: LenientDictionaryKey {}
- Key failures always drop their entry (reported to the debug logger with the raw JSON key) — a key has no nil-shaped hole to pad.
- New compile-time diagnostics with fix-its for invalid shapes: non-optional values under padding, optional values under drop, optional keys (
[K?: V]), andDictionary<K, V>longhand. - Dictionary overloads of the
LenientDecodingruntime helpers, callable from hand-writteninit(from:)too.
Migration notes
- A lenient
[K: V]?property (non-optional values) that compiled under 1.0.0 with whole-value leniency now produces a compile-time error with fix-its — apply the fix-it to[K: V?]?for per-entry padding, or mark it@Strictto keep synthesized behavior. - A lenient
[K: V?]?property now pads per entry instead of nil-ing the whole dictionary when a single entry is broken. If you relied on whole-value semantics, mark the property@Strict. @Strictdictionary properties are untouched — byte-for-byte synthesized behavior.
Full Changelog: v1.0.0...v1.1.0