Tagged articles
3 articles
Page 1 of 1
NetEase Cloud Music Tech Team
NetEase Cloud Music Tech Team
Jul 15, 2022 · Mobile Development

Swift JSON Decoding Solutions: Comparison and Custom Implementation

The article surveys common Swift JSON decoding approaches—including manual Unbox, HandyJSON, Sourcery, built-in Codable and BetterCodable—highlights their strengths and weaknesses, then presents a custom NEJSONDecoder that adds default values, key mapping, type compatibility, tolerant error handling, and transformation support, with performance benchmarks.

BetterCodableCodableDecoder
0 likes · 23 min read
Swift JSON Decoding Solutions: Comparison and Custom Implementation
Liulishuo Tech Team
Liulishuo Tech Team
Apr 19, 2018 · Mobile Development

Using Swift 4.1 JSONEncoder/JSONDecoder KeyEncodingStrategy to Bridge Snake_case and CamelCase and Create Custom Key Strategies

This article explains how Swift 4.0 introduced Codable, how Swift 4.1 added keyEncodingStrategy and keyDecodingStrategy to automatically convert between snake_case and camelCase, and how to implement custom key transformations such as PascalCase using the .custom strategy.

CodableJSONKeyEncodingStrategy
0 likes · 9 min read
Using Swift 4.1 JSONEncoder/JSONDecoder KeyEncodingStrategy to Bridge Snake_case and CamelCase and Create Custom Key Strategies