Created
August 16, 2018 12:18
-
-
Save Abhishek9634/2b23c069fa1b43ee9d92cfe1d23d60fc to your computer and use it in GitHub Desktop.
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 | |
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