Skip to content

Instantly share code, notes, and snippets.

@Abhishek9634
Created August 16, 2018 12:18
Show Gist options
  • Save Abhishek9634/2b23c069fa1b43ee9d92cfe1d23d60fc to your computer and use it in GitHub Desktop.
Save Abhishek9634/2b23c069fa1b43ee9d92cfe1d23d60fc to your computer and use it in GitHub Desktop.
import Foundation
import JSONParsing
public final class Beer: JSONParseable {
public var abv: String
public var ibu: String
public var id: Int
public var name: String
public var style: String
public var ounces: Int
init(abv: String,
ibu: String,
id: Int,
name: String,
style: String,
ounces: Int) {
self.abv = abv
self.ibu = ibu
self.id = id
self.name = name
self.style = style
self.ounces = ounces
}
public static func parse(_ json: JSON) throws -> Beer {
return try Beer(abv: json["abv"]^,
ibu: json["ibu"]^,
id: json["id"]^,
name: json["name"]^,
style: json["style"]^,
ounces: json["ounces"]^)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment