I am not getting what to do please help me the error is:
Type 'Any' has no subscript members
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var Lab: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
if let url = URL(string: "MY URL")
{
processData(url: url);
}
}
private func processData(url: URL)
{
let task = URLSession.shared.dataTask(with: url) { (data, response, error) -> Void in
if error != nil {
print(error)
} else {
if let result = data
{
do{
let json = try JSONSerialization.jsonObject(with: result, options:JSONSerialization.ReadingOptions.mutableContainers)
print(json)
if let name = json["bname"] as? String
{
print (name);
} }
catch let error as NSError
{
print("error is \(error)")
}
}
}
}
task.resume()
}
}
And My JSON is:
{
"bank_detail" = (
{
0 = 1;
1 = www;
2 = "PRAKHAR SONI";
3 =123;
4 = UDAIPUR;
5 = ee;
6 = 3190;
7 = "2017-03-15";
8 = "2017-03-15 13:31:39";
accno = 123;
bid = 1;
bname = www;
"branch_code" = 3190;
"branch_name" = UDAIPUR;
date = "2017-03-15";
"date_time" = "2017-03-15 13:31:39";
ifsc = www;
uname = "PRAKHAR SONI";
},
{
0 = 3;
1 = "www ";
2 = "Sureshkumar Soni";
3 = "123 ";
4 = "UDAIPUR ";
5 = "www ";
6 = "3190 ";
7 = "2017-03-17";
8 = "2017-03-17 12:24:24";
accno = "www ";
bid = 3;
bname = "www ";
"branch_code" = "3190 ";
"branch_name" = "UDAIPUR ";
date = "2017-03-17";
"date_time" = "2017-03-17 12:24:24";
ifsc = "www ";
uname = "Sureshkumar Soni";
}
);
}