Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
クリぼっちの自分が信じられるのはもはや型のみである
Search
Ryota Sakaguchi
December 25, 2018
Technology
510
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
クリぼっちの自分が 信じられるのは もはや型のみである
Ryota Sakaguchi
December 25, 2018
Transcript
16 slides
{ "shop": { "id": 1, "name": "", "employees": [ {
"id": 1, "job_id": 1, "name": "kuluna" } ] } }
import Foundation struct Employee: Decodable { let id: Int let
job_id: Int let name: String } struct Shop: Decodable { let id: Int let name: String let employees: [Employee] } struct ShopResponse: Decodable { let shop: Shop }
let response = try! JSONDecoder().decode( ShopResponse.self, from: json.data(using: .utf8)! )
print(response.shop.name) // “”
☺
let shop = response.shop shop.id == shop.employees.first?.job_id
let newEmployee = Employee( id: shop.id, job_id: 0, name: "Sakaguchi"
)
!
-
!
struct ShopId: Codable, Equatable { let value: Int init(_ value:
Int) { self.value = value } public init(from decoder: Decoder) throws { self.value = try decoder.singleValueContainer().decode(Int.self) } public func encode(to encoder: Encoder) throws { var c = encoder.singleValueContainer() try c.encode(self.value) } }
struct Shop: Decodable { let id: ShopId let name: String
let employees: [Employee] }
☺ ☺ Comparable
More Decks by Ryota Sakaguchi
See All by Ryota Sakaguchi
大切なことは全てLintが教えてくれた
kuluna
0
64
時間を意識する推しツールたち / Time-aware tools
kuluna
1
660
DroidKaigi2020 - Data Bindingのイロハ
kuluna
1
1.5k
チームでつくる RESTful API
kuluna
1
12k
Other Decks in Technology
See All in Technology
常時稼働エージェントの作り方(Claude公式ブログを資料化)
minorun365
PRO
16
27k
20261113_JAWS_Osaka
takuyay0ne
1
580
小さなエージェントから始めてみよう!実践コンテキストエンジニアリング
iwamot
PRO
0
130
[関西Kaggler会 20261113] 続・コミュニティコンペのススメ
nejumi
0
140
Go初心者のクラウドエンジニアが、デプロイを通して旨味を知っていく話
ryudai
1
230
プロダクションコードにおける encoding/json から encoding/json/v2 へのスムーズな移行
sansantech
PRO
1
450
CloudTrail を推したい
kazzpapa3
1
130
HTTP通信に使おうとすると実はめんどくさいfile_get_contents
maguroalternative
0
200
専門家に使ってもらうAIプロダクトをつくる - 病院の医事課向けDPCコーディング支援システムの設計と評価
hagino3000
4
650
異夢同船〜異なる夢でも同じ船でなんとかする〜
fortegp05
1
500
さようならSSH鍵、こんにちはゼロトラスト ― AIフレンドリーで快適な自宅鯖SSH
atalie2m
14
6.9k
BALLAS Technology Deck
ballas_inc
0
840
Featured
See All Featured
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.3k
SEO for Brand Visibility & Recognition
aleyda
0
4.9k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.7k
Ruling the World: When Life Gets Gamed
codingconduct
0
440
Game over? The fight for quality and originality in the time of robots
wayneb77
1
330
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
380
Being A Developer After 40
akosma
PRO
92
590k
Writing Fast Ruby
sferik
630
63k
Embracing the Ebb and Flow
colly
88
5.2k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Paper Plane
katiecoart
PRO
6
55k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
520