swift4.0 data转json

func nsdataToJSON(data: NSData) -> AnyObject? {
    do {
        return try JSONSerialization.jsonObject(with: data as Data, options: .mutableContainers) as AnyObject
    } catch {
        print(error)
    }
    return nil
}

你可能感兴趣的:(swift4.0 data转json)