Earlier method

let json = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) 

returned AnyObject , which was easily converted to a Dictionary . B Swift 3 we have a trace.

 open class func jsonObject(with data: Data, options opt: JSONSerialization.ReadingOptions = []) throws -> Any 

How can I convert Any to Dictionary ?

    1 answer 1

    You are a little misunderstood. It still AnyObject , but throws Any in the case of an exception.

    To get JSON type:

     let object: AnyObject = try JSONSerialization.jsonObject(with: data, options: options) 

    (well and do-catch errors)