-
-
Save Pasanpr/68b577c857fcbc1e0b5be9d50803511d to your computer and use it in GitHub Desktop.
Starter code for S3:V1 - Wrapper Keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let json = """ | |
{ | |
"work": { | |
"id": 2422333, | |
"popularity": null, | |
"sponsor": "Random Publisher, Inc", | |
"books_count": 222, | |
"ratings_count": 860687, | |
"text_reviews_count": 37786, | |
"best_book": { | |
"id": 375802, | |
"title": "Ender's Game (Ender's Saga, #1)", | |
"author": { | |
"id": 589, | |
"name": "Orson Scott Card" | |
} | |
} | |
} | |
} | |
""".data(using: .utf8)! | |
struct SearchResult { | |
let id: Int | |
let booksCount: Int | |
let ratingsCount: Int | |
let textReviewsCount: Int | |
} | |
let decoder = JSONDecoder() | |
decoder.keyDecodingStrategy = .convertFromSnakeCase | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment