Module 07 Β· Talking to the Backend β Lesson 2 of 4 Β· ~12 min
Decoding Real-World JSON
Dates: the classic networking pain
JSON has no date type. None. It has strings, numbers, booleans, arrays, and objects β so every backend on Earth ships dates as strings, like "2026-07-01T15:00:00Z". That format is called ISO-8601: year-month-day, a T, the time, and a timezone (Z means UTC, "universal time").
Swift's Date type, on the other hand, is a real point in time you can compare and format. Somebody has to bridge the two β and that somebody is JSONDecoder, via its dateDecodingStrategy property. Set it once and every Date field in every struct decodes automatically.