jweinst1
10/16/2016 - 5:25 AM

Swift 3 get json serialization from url

Swift 3 get json serialization from url

func getJSON(address:String) -> AnyObject {
    let url = NSURL(string: address)!
    let jsonData = NSData(contentsOf: url as URL)!
    return try! JSONSerialization.jsonObject(with: jsonData as Data, options: []) as AnyObject
}

print(getJSON(address: "https://www.reddit.com/r/Politics/.json"))