I am trying to convert the following code from this library ( https://github.com/dankogai/swift-json ) to Swift 3 compatibility code.
I am stuck on this line though.
obj = try JSONSerialization.jsonObject(
The error I get: jsonObject creates "Any" and not the expected type of the context result "AnyObject?"
The code before I try to convert to swift 3 in its full context is below.
public convenience init(data:NSData) { var err:NSError? var obj:AnyObject? do { obj = try NSJSONSerialization.JSONObjectWithData( data, options:[]) } catch let error as NSError { err = error obj = nil } self.init(err != nil ? err! : obj!) }
json ios10 swift swift2 swift3
Joseph Astrahan
source share