Hi @Claude31,
Thank you for the response! After redoing the naming conventions and creating the coding keys, the first problem was my URL request, which then once I fixed (and validated by printing the response) I then couldn't seem to get the response to parse into the individual "ValueData" elements...
func getMember (completion: @escaping(Result<[ValueData], WasatchError>) -> Void){
let task = URLSession.shared.dataTask(with: resourceRequest) {(data, response, error) in
guard let jsonData = data else {
completion(.failure(.noData))
return }
do {
let wasatchResponse = try JSONDecoder().decode(WasatchResponse.self, from: jsonData)
let values = wasatchResponse.value
completion(.success(values))
}catch{
completion(.failure(.cannotProcessData))
}
print(String(data: jsonData, encoding: .utf8)!)
}
task.resume()
}
What's interesting is that last print statement still shows me the JSON structure I'm looking for, however for some reason I'm still throwing the "completion(.failure(.cannotProcessData))" statement.
Could having non-matching data types make the JSON parsing fail? (i.e. my struct defining a string when the JSON response is a bool?)
Post
Replies
Boosts
Views
Activity
Sure! The following is what we are looking for...
{
		"@odata.context": "$metadata#Member",
		"value": [
				{
						"MemberKeyNumeric": 87205,
						"OfficeKeyNumeric": 70083,
						"MemberAORkey": "M00000628",
						"MemberAddress1": "230 West Towne Ridge Pkwy",
						"MemberAddress2": "",
						"MemberCity": "Sandy",
						"MemberFax": "",
						"MemberFirstName": "XBroker",
						"MemberFullName": "XBroker Test",
						"MemberKey": "87205",
						"MemberLastName": "Test",
						"MemberMiddleName": "",
						"MemberMlsId": "87205",
						"MemberMobilePhone": "801-676-5400",
						"MemberNationalAssociationId": "12345",
						"MemberOfficePhone": "801-676-5400",
						"MemberPostalCode": "84070",
						"MemberPreferredPhone": "801-676-5400",
						"MemberStateLicense": "0",
						"OfficeKey": "70083",
						"OfficeMlsId": "70083",
						"OfficeName": "Fake Brokerage",
						"OriginatingSystemMemberKey": "M00000628",
						"OriginatingSystemName": "UtahRealEstate.com",
						"MemberMlsAccessYN": true,
						"ModificationTimestamp": "2020-12-18T16:23:49Z",
						"OriginalEntryTimestamp": null,
						"MemberAOR": "Salt Lake Board",
						"MemberCountry": "",
						"MemberCountyOrParish": "",
						"MemberStateLicenseState": "UT",
						"MemberStateOrProvince": "UT",
						"MemberStatus": "Active",
						"MemberType": "MLS Only Broker",
						"MemberDesignation": ""
				}
		]
}
And that makes more sense, I was wondering if the types would affect the outcome. I can go through the data dictionary to ensure I am getting the correct types for each of these fields.