목록JSON 패싱 (1)
DEV_Larva

Decodable JSON과 같은 외부 representation으로부터 인스턴스를 생성하기 위한 메커니즘을 제공하는 프로토콜 해당 프로토콜을 이용하면 인스턴스를 자동으로 디코딩할 수 있다. EX) - Decodable 사용 구조체 struct User: Decodable { var name: String var age: Int } - JSON 데이터 let json = """ { "name": "nelchupapa", "age": 26 } """.data(using: .utf8)! let decoder = JSONDecoder() let user = try decoder.decode(User.self, from: json) print(user.name) // "nelchupapa" print(user...
SwiftUI & UIKit/Network
2023. 11. 11. 15:43