Skip to content

Instantly share code, notes, and snippets.

@Pasanpr
Created March 28, 2018 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pasanpr/68b577c857fcbc1e0b5be9d50803511d to your computer and use it in GitHub Desktop.
Save Pasanpr/68b577c857fcbc1e0b5be9d50803511d to your computer and use it in GitHub Desktop.
Starter code for S3:V1 - Wrapper Keys
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