Post

Replies

Boosts

Views

Activity

Reply to JSON DATA CORRUPTED ERROR
ataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around line 1, column 0." UserInfo={NSDebugDescription=Invalid value around line 1, column 0., NSJSONSerializationErrorIndex=0}))) dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/eshansingh/Library/Developer/Xcode/DerivedData/EmployeeManagement-bfquzjwgjywziwfrfyygkodtlgop/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/eshansingh/Library/Developer/Xcode/DerivedData/EmployeeManagement-bfquzjwgjywziwfrfyygkodtlgop/Build/Products/Debug-iphonesimulator CoreSimulator 783.5 - Device: iPhone 11 (118C63BF-B908-4454-8870-FC609C41BA8D) - Runtime: iOS 15.2 (19C51) - DeviceType: iPhone 11 (lldb)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
My Views Code are as follows Orders are arranged properly. in the actual app struct ETabView: View {     var body: some View {         TabView{             PeopleView().tabItem{                 VStack{                    Image(systemName:"person.3")                    Text("Current Employees")                 }                                  }             DisplayPreferenceView().tabItem{                 VStack{                  Image(systemName:"gearshape")                  Text("Perference")                 }             }                                                                          }     } } struct TabView_Previews: PreviewProvider {     static var previews: some View {         ETabView()     } } struct PeopleView: View { @EnvironmentObject var model:EmployeeModel     var body: some View {         List(model.person){ p in             VStack{             Text("Name:" + p.Name)             Text("Address:" + p.Address)             Text("Company:" + p.Company)             Text("YearsofExperience:" + String(p.YearsofExperience))             }         }     } } struct PeopleView_Previews: PreviewProvider {     static var previews: some View {         PeopleView()     } starting point of app ```import SwiftUI @main struct EmployeeManagementApp: App {     var body: some Scene {         WindowGroup {             ETabView()                 .environmentObject(EmployeeModel())         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
my data fetching code is as follows (forgot to add in the question) import Foundation class DataFetching {          static func getLocalData() -> [Person] {                  // Parse local json file                  // Get a url path to the json file         let pathString = Bundle.main.path(forResource: "data", ofType: "json")                  // Check if pathString is not nil, otherwise...         guard pathString != nil else {             return [Person]()         }                  // Create a url object         let url = URL(fileURLWithPath: pathString!)                  do {             // Create a data object             let data = try Data(contentsOf: url)                          // Decode the data with a JSON decoder             let decoder = JSONDecoder()                          do {                                  let EmployeeData = try decoder.decode([Person].self, from: data)                                  // Add the unique IDs                 for e in EmployeeData {                     e.id = UUID()                 }                 // Return the recipes                 return EmployeeData             }             catch {                 // error with parsing json                 print(error)             }         }         catch {             // error with getting data             print(error)         }                  return [Person]()     }      }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
it is not allowing me to post any code or attachments . i created the json file inside the project so the path should not be a problem?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
that's my actual json file in the question
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
ataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around line 1, column 0." UserInfo={NSDebugDescription=Invalid value around line 1, column 0., NSJSONSerializationErrorIndex=0}))) dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/eshansingh/Library/Developer/Xcode/DerivedData/EmployeeManagement-bfquzjwgjywziwfrfyygkodtlgop/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/eshansingh/Library/Developer/Xcode/DerivedData/EmployeeManagement-bfquzjwgjywziwfrfyygkodtlgop/Build/Products/Debug-iphonesimulator CoreSimulator 783.5 - Device: iPhone 11 (118C63BF-B908-4454-8870-FC609C41BA8D) - Runtime: iOS 15.2 (19C51) - DeviceType: iPhone 11 (lldb)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
yes this is what I was also expecting but mine keeps crashing.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
There is are no extra lines in the actual app code. it is just happening here. please tell what wrong and avoid the blank lines
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
what's wrong in the code ?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
My Views Code are as follows Orders are arranged properly. in the actual app struct ETabView: View {     var body: some View {         TabView{             PeopleView().tabItem{                 VStack{                    Image(systemName:"person.3")                    Text("Current Employees")                 }                                  }             DisplayPreferenceView().tabItem{                 VStack{                  Image(systemName:"gearshape")                  Text("Perference")                 }             }                                                                          }     } } struct TabView_Previews: PreviewProvider {     static var previews: some View {         ETabView()     } } struct PeopleView: View { @EnvironmentObject var model:EmployeeModel     var body: some View {         List(model.person){ p in             VStack{             Text("Name:" + p.Name)             Text("Address:" + p.Address)             Text("Company:" + p.Company)             Text("YearsofExperience:" + String(p.YearsofExperience))             }         }     } } struct PeopleView_Previews: PreviewProvider {     static var previews: some View {         PeopleView()     } starting point of app ```import SwiftUI @main struct EmployeeManagementApp: App {     var body: some Scene {         WindowGroup {             ETabView()                 .environmentObject(EmployeeModel())         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
anyone ?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
Added the code please help out
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
my data fetching code is as follows (forgot to add in the question) import Foundation class DataFetching {          static func getLocalData() -> [Person] {                  // Parse local json file                  // Get a url path to the json file         let pathString = Bundle.main.path(forResource: "data", ofType: "json")                  // Check if pathString is not nil, otherwise...         guard pathString != nil else {             return [Person]()         }                  // Create a url object         let url = URL(fileURLWithPath: pathString!)                  do {             // Create a data object             let data = try Data(contentsOf: url)                          // Decode the data with a JSON decoder             let decoder = JSONDecoder()                          do {                                  let EmployeeData = try decoder.decode([Person].self, from: data)                                  // Add the unique IDs                 for e in EmployeeData {                     e.id = UUID()                 }                 // Return the recipes                 return EmployeeData             }             catch {                 // error with parsing json                 print(error)             }         }         catch {             // error with getting data             print(error)         }                  return [Person]()     }      }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
do you mean date or data
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22