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
Unbox
Search
misyobun
March 01, 2016
Programming
1.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Unbox
shibuya.swift #3
misyobun
March 01, 2016
More Decks by misyobun
See All by misyobun
大容量データのダウンロード戦略
misyobun
3
14k
トラウマ
misyobun
0
1.1k
GeoPlayerを使ってアプリをデバッグする
misyobun
0
700
Joda-timeをAndroidで使う話
misyobun
4
1k
aarの配備をちょっとだけ楽する話
misyobun
1
290
アノテーションでちょっとだけ楽する話
misyobun
1
540
Other Decks in Programming
See All in Programming
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
280
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
200
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
390
FreeBSDでZabbixを動かす
kenkino
0
320
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
120
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
160
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.7k
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
1
9.2k
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
910
一人だけ、Kiroが静止する日
hideg
0
130
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
220
wkhtmltopdfの次どうするか問題2026
willnet
2
1.6k
Featured
See All Featured
Deep Space Network (abreviated)
tonyrice
0
320
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
680
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
330
The Curse of the Amulet
leimatthew05
3
15k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
510
The Art of Programming - Codeland 2020
erikaheidi
57
14k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Google's AI Overviews - The New Search
badams
0
1.6k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Transcript
UNBOX IT’S EASY TO USE SWIFT JSON DECODER SHIBUYA.SWIFT #3
!misyobun
JSON LIBRARIES FOR SWIFT THERE ARE SO MANY !!!!!!!!!!!!! I
WANT TO INTRODUCE ONE OF THEM TO YOU
JSON LIBRARY FOR SWIFT THERE ARE SO MANY !!!!!!!!!!!!! I
WANT TO INTRODUCE ONE OF THEM TO YOU. UNBOX https://github.com/JohnSundell/Unbox
UNBOX { "title": "͕ͯ͢FʹͳΔ", "summary": "16ਐදه", "comment": "4ͭͰ͢" } struct
Book { var title: String var summary: String var comment: String }
UNBOX struct Book : Unboxable{ var title: String var summary:
String var comment: String init(unboxer: Unboxer) { self.title = unboxer.unbox("title") self.summary = unboxer.unbox("summary") self.comment = unboxer.unbox("comment") } } let book: Book? = Unbox(data)
UNBOX struct Book : Unboxable{ var title: String var review:
String var comment: String init(unboxer: Unboxer) { self.title = unboxer.unbox("title") self.review = unboxer.unbox("review") self.comment = unboxer.unbox("comment") } } do { let book: Book? = UnboxOrThrow(data) }catch{ // Error handling }
UNBOX [ "subject": { color = 1e8bc3; name = English;
number = 200;}, "content": ڭ͍͑ͯͩ͘͞ʂ, "grade": { name = "Senior High"; number = 500;}, "created_at": 2016-03-01T14:59:47Z, "id": 12646, "answers_count": 0, "user": { "avatar_url" = "https://s3/ൿີ/hajisirazu/file/4883/01456642777925.jpg?AWSAccessKeyId=?"; id = 303695; name = "tarop"; }, "status": active, "images": ( { height = 891; id = 4883; status = active; "thumb_l_url" = "https://s3/ൿີ/hajisirazu/file/7777/thumb_l_01456642777925.jpg?AWSAccessKeyId=?; "thumb_s_url" = "https://s3/ൿີ/hajisirazu/file/7777/thumb_s_01456642777925.jpg?AWSAccessKeyId=?"; url = "https://s3/ൿີ/hajisirazu/file/4883/01456642777925.jpg?AWSAccessKeyId=?"; width = 557; }) ]
UNBOX struct Grade : Unboxable{ let number: Int let name:
String init(unboxer: Unboxer) { self.number = unboxer.unbox("number") self.name = unboxer.unbox("name") } } struct Subject :Unboxable{ let number: Int let name: String let color :String init(unboxer: Unboxer) { self.number = unboxer.unbox("number") self.color = unboxer.unbox("color") self.name = unboxer.unbox("name") } }
UNBOX struct User: Unboxable { let ID: Int let name:
String let avatarUrl :String init(unboxer: Unboxer) { self.ID = unboxer.unbox("id") self.name = unboxer.unbox("name") self.avatarUrl = unboxer.unbox("avatar_url") } } struct Image: Unboxable { let height: Int let width :Int let id :Int let status :String let thumbLUrl :NSURL let thumbSUrl :NSURL let url :NSURL init(unboxer: Unboxer) { self.height = unboxer.unbox("height") self.width = unboxer.unbox("width") self.id = unboxer.unbox("id") self.status = unboxer.unbox("status") self.thumbLUrl = unboxer.unbox("thumb_l_url") self.thumbSUrl = unboxer.unbox("thumb_s_url") self.url = unboxer.unbox("url") } }
UNBOX struct Question: Unboxable { let ID: Int let content:
String let user: User let subject: Subject? let grade: Grade? let createdAt: String let answersCount: Int let status: String let images: [Image?] init(unboxer: Unboxer) { self.ID = unboxer.unbox("id") self.content = unboxer.unbox("content") self.user = unboxer.unbox("user") self.subject = unboxer.unbox("subject") self.grade = unboxer.unbox("grade") self.createdAt = unboxer.unbox("created_at") self.answersCount = unboxer.unbox("answers_count") self.status = unboxer.unbox("status") self.images = unboxer.unbox("images") } } let question: Question? = Unbox(jsonData)
UNBOX TRANSFORMATIONS Unbox supports transformations that let you treat any
value or object as if it was a raw JSON type. struct UniqueIdentifier: UnboxableByTransform { typealias UnboxRawValueType = String let identifierString: String init?(identifierString: String) { if let UUID = NSUUID(UUIDString: identifierString) { self.identifierString = UUID.UUIDString } else { return nil } } init() { self.identifierString = NSUUID().UUIDString } static func transformUnboxedValue(unboxedValue: String) -> UniqueIdentifier? { return UniqueIdentifier(identifierString: unboxedValue) } static func unboxFallbackValue() -> UniqueIdentifier { return UniqueIdentifier() } }
UNBOX OK. I KNOW WHAT YOU ARE ABOUT TO SAY
TO ME.
UNBOX class Author : RLMObject, Unboxable { var name: String
= "" var age: Int = 0 required convenience init(unboxer: Unboxer) { self.init() self.name = unboxer.unbox("name") self.age = unboxer.unbox("age") } }
UNBOX IT’S SIMILAR TO OBJECTMAPPER !!!!!!!!
UNBOX ENUM SUPPORT enum Android: Int, UnboxableEnum { case IceCreamSandwich
case JellyBean case KitKat case Lollipop case Marshmallow static func unboxFallbackValue() -> Android { return .IceCreamSandwich } }
UNBOX CONTEXTUAL OBJECTS SUPPORT let author: Author? = try UnboxOrThrow(authorJson)
let book: Book? = try UnboxOrThrow(bookJSON, context: author) UNBOX HAS HAD SUPPORT FOR PASSING AN OPTIONAL CONTEXT OBJECT INTO THE UNBOXING PROCESS.
UNBOX struct Book : UnboxableWithContext{ var title: String var body:
String var comment: String var author: Author? var description : String { return "this is description" } init(unboxer: Unboxer,context:Author) { self.title = unboxer.unbox("title") self.body = unboxer.unbox("body") self.comment = unboxer.unbox("comment") self.author = context } } let author:Author? = Unbox(authorJson) let book:Book? = Unbox(bookJson, context:author)
UNBOX USE WHAT YOU LIKE !
UNBOX THANKS ! https://github.com/JohnSundell/Unbox https://github.com/Hearst-DD/ObjectMapper