Read Json with Swift and macOS

I could find different ways to read JSON with iOS. But I cannot figure it with macOS.

Here is what I tried:

// Outside Class ViewController:

struct User: Codable {
    let name: String
    let email: String
    let address: Address
}
struct Address: Codable {
    let street: String
    let city: String
}

// in viewDidLoad:

let url = URL(string: "https:jsonplaceholder.typicode.com/users")!
URLSession.shared.dataTask(with: url) { data, _, _ in
    if let data = data {
        let users = try? JSONDecoder().decode([User].self, from: data)
        print (users![0].address.street)
    }
}.resume()