All posts

Posts tagged with: Codable

7 posts found

Close-up of a red wax seal pressed onto a folded paper envelope
Swift Codable

Your Request Signature Fails on One Request in Ten. JSONEncoder Never Promised You the Same Bytes.

Signing a JSON body with HMAC in Swift breaks when you encode twice, when a Dictionary changes key order, or when JSONEncoder escapes slashes as \/. Here's why JSONEncoder output isn't canonical, how it breaks webhook and API signatures, and the fix: sign the exact Data you send.

9 min read
A plain cardboard box with no label sitting alone on a wooden floor
Swift Codable

Your Backend Added One Enum Case. Every User on the Old App Build Got an Empty Screen.

A Swift enum with a String raw value and synthesized Codable throws on any value it doesn't know, and that one throw takes down the whole object and the whole array around it. Here's how a harmless server-side addition empties your iOS app, the unknown-case and other(String) fixes, the encode-back trap, and the test that catches it before the App Store does.

9 min read
Close-up of paper calendar pages with printed dates
Swift iOS Development

JSONEncoder Sends Your Dates as Seconds Since 2001. Your Backend Thinks It's 1995.

Swift's JSONEncoder defaults to .deferredToDate, which encodes Date as a Double counting seconds from January 1, 2001, not 1970. Here's why round-trip tests never catch it, what it does to Node, Python and Go backends, and how to pin one date strategy for your whole app.

8 min read
A wall of brass post office boxes, one standing open and empty among the closed doors
Swift iOS Development

Codable Can't Tell You the Difference Between null and a Missing Key. Your PATCH Endpoint Can.

decodeIfPresent collapses an explicit JSON null and an absent key into the same nil, which makes 'clear this field' and 'leave it alone' indistinguishable. Here's the three-state wrapper that keeps them apart, and when you actually need it.

7 min read
A tray of metal letterpress type blocks, capital and lowercase letters sorted side by side
Swift iOS Development

Swift's uuidString Is Uppercase. Your Backend's UUIDs Aren't. Every String Comparison Between Them Fails.

UUID().uuidString returns uppercase hex while Postgres, JavaScript and Python emit lowercase, so string comparisons, dictionary keys, cache file names and Set deduplication silently miss. Here's where it bites in iOS apps and how to keep UUIDs typed until the boundary.

8 min read
Close-up of mismatched mechanical gears, the kind of quiet misalignment that convertToSnakeCase produces on acronym-heavy property names
Swift Codable

Codable's Snake Case Conversion Looks Like Free API Mapping. It Breaks on the First Acronym.

JSONEncoder's .convertToSnakeCase and JSONDecoder's .convertFromSnakeCase promise to erase the naming gap between Swift and your API. They do — right up until a property has an acronym in it, and then they fail silently on Optional fields instead of throwing.

5 min read
A broken metal chain link isolated against a plain background
Swift Codable

One Bad Element in Your JSON Array Can Freeze Your App Forever. Swift Wants to Fix It.

A fresh Swift Evolution pitch adds skip() to UnkeyedDecodingContainer, fixing a real Codable footgun: the 'decode what you can, skip what you can't' loop that looks correct and hangs at runtime.

7 min read