Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
mobile ruleP2stack specificStack: swift
swiftcodablejsonnaming
Map snake_case JSON to camelCase with CodingKeys
Keep Swift properties camelCase and map wire names via CodingKeys (or a keyDecodingStrategy) instead of naming properties snake_case.
PR: mobile-mining-2026-06Created: Jul 5, 2026
Bad example
Old codeswift
| 1 | struct Token { let access_token: String } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codeswift
| 1 | struct Token: Decodable { let accessToken: String |
| 2 | enum CodingKeys: String, CodingKey { case accessToken = "access_token" } } |
Explanation (EN)
Objašnjenje (HR)