What problem does it solve?
Swift Codable can be hard to get right when JSON keys don’t match your model, dates use different formats, arrays contain mixed types, or encoding/decoding must integrate with networking, persistence, or user defaults.
Core Features & Use Cases
- Custom key mapping: Use CodingKeys and decoder/encoder key strategies to handle snake_case and renamed fields.
- Custom decoding/encoding: Implement init(from:) and encode(to:) for transformations like epoch-to-Date conversion and derived fields.
- Robust decoding patterns: Handle nested/flattened containers, heterogeneous arrays via discriminators, lossy array decoding, and missing-key defaults.
- Integration-ready: Apply consistent Codable configuration with JSONEncoder/JSONDecoder for URLSession, SwiftData, and UserDefaults.
Use Case: You receive an API response where timestamps are Unix epoch numbers, keys are snake_case, and a single field is an array of mixed “text” and “image” objects; use this Skill to model it cleanly with safe decoding and deterministic encoding for tests.
Quick Start
Use the swift-codable skill to generate Codable models and decoding/encoding logic for your specific JSON shape, including custom key mapping, date parsing strategy, and any heterogeneous or lossy arrays.