I don't why, my json file is throwing an error as being corrupted even though json file is valid. (I have checked from json validator). Here is my code: My model:
`import Foundation
class Person:Identifiable,Decodable{
var id:UUID?
var Name:String
var Address:String
var Company:String
var YearsofExperience:Int
}
My JSON File
[{
"Name":"Inigo Montoya",
"Address":"555 YouKilled My father Street",
"Company":"CodeWithChris",
"YearsofExperience":35
},
{
"Name":"Edna Mode",
"Address":"123 Nocape Lane",
"Company":"CodeWithChris",
"YearsofExperience":177
},
{
"Name":"Travis Bickle",
"Address":"99 Youtalkingtome Road",
"Company":"CodeWithChris",
"YearsofExperience":99
},
{
"Name":"Walter Sobchak",
"Address":"8 Dude Place",
"Company":"CodeWithChris",
"YearsofExperience":23
},
{
"Name":"Jullis Winnfield",
"Address":"25 Ezekiel Ave",
"Company":"CodeWithChris",
"YearsofExperience":17
}]
ViewModel:
import Foundation
class EmployeeModel:ObservableObject{
@Published var person = [Person]()
init(){
person.self = DataFetching.getLocalData()
}
}
Can you share the code that populates your date model from the json?
do you mean date or data
Added the code please help out