Member-only story

Advanced Codable: Missing Fields In Arrays (Swift)

Decode without try

Steven Curtis
3 min readJan 4, 2023
Photo by Xavier von Erlach on Unsplash

Difficulty: Beginner | Easy | Normal | Challenging

This article has been developed using Xcode 14.2, and Swift 5.7.2

This article is “inspired” by the current implementation of Decodable. If we have missing fields in an Array which we wish to decode, what are we to do?

Read on to find out what can possibly be done about this!

Prerequisites:

Terminology:

Decodable: A type that can decode itself from an external representation

JSON: JavaScript Object Notation, a lightweight format for storing and transporting data

The Code

The Basics

try** this

--

--

Responses (2)