What problem does it solve?
Mapping JSON and property-list data to strongly typed Swift models is error prone and time consuming, especially when APIs use different key naming, nested structures, inconsistent arrays, or varied date formats. This Skill provides patterns and guidance to reliably decode incoming data, encode outgoing payloads, and integrate serialization with networking and local storage.
Core Features & Use Cases
- Automatic Codable synthesis for simple models and guidance on choosing Encodable, Decodable, or Codable.
- Custom CodingKeys, nested container handling, and custom init(from:) / encode(to:) for transformations and flattened JSON.
- Date, data, and key decoding/encoding strategies, lossy array decoding, single-value containers, and deterministic encoder configuration for tests.
- Integration examples for URLSession networking, SwiftData composite attributes, and storing Codable types in UserDefaults.
- Real-world use case: decode heterogeneous content arrays from an API, remap snake_case keys to camelCase, and supply defaults for missing fields.
Quick Start
Decode an API response into a Swift model by configuring JSONDecoder with the appropriate date and key strategies and then decode the top-level payload into your Decodable type.