How can I print the country value from my JSON file in Swift?

dataFromJson is array of UserData, so you need to iterate like this.


do {
                let data =  try Data(contentsOf: fileLocation)
                let jsonDecoder = JSONDecoder()
                let dataFromJson = try jsonDecoder.decode([UserData].self, from: data)
                
                self.userData = dataFromJson
                dataFromJson.forEach{ user in

                    print(user.state)

                }
                
                print(userData)
                
                
            } catch {
                print(error)
            }