Post

Replies

Boosts

Views

Activity

Reply to Parsing JSON GET response with special characters
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?)
Jan ’21
Reply to Parsing JSON GET response with special characters
Sure! The following is what we are looking for... { &#9;&#9;"@odata.context": "$metadata#Member", &#9;&#9;"value": [ &#9;&#9;&#9;&#9;{ &#9;&#9;&#9;&#9;&#9;&#9;"MemberKeyNumeric": 87205, &#9;&#9;&#9;&#9;&#9;&#9;"OfficeKeyNumeric": 70083, &#9;&#9;&#9;&#9;&#9;&#9;"MemberAORkey": "M00000628", &#9;&#9;&#9;&#9;&#9;&#9;"MemberAddress1": "230 West Towne Ridge Pkwy", &#9;&#9;&#9;&#9;&#9;&#9;"MemberAddress2": "", &#9;&#9;&#9;&#9;&#9;&#9;"MemberCity": "Sandy", &#9;&#9;&#9;&#9;&#9;&#9;"MemberFax": "", &#9;&#9;&#9;&#9;&#9;&#9;"MemberFirstName": "XBroker", &#9;&#9;&#9;&#9;&#9;&#9;"MemberFullName": "XBroker Test", &#9;&#9;&#9;&#9;&#9;&#9;"MemberKey": "87205", &#9;&#9;&#9;&#9;&#9;&#9;"MemberLastName": "Test", &#9;&#9;&#9;&#9;&#9;&#9;"MemberMiddleName": "", &#9;&#9;&#9;&#9;&#9;&#9;"MemberMlsId": "87205", &#9;&#9;&#9;&#9;&#9;&#9;"MemberMobilePhone": "801-676-5400", &#9;&#9;&#9;&#9;&#9;&#9;"MemberNationalAssociationId": "12345", &#9;&#9;&#9;&#9;&#9;&#9;"MemberOfficePhone": "801-676-5400", &#9;&#9;&#9;&#9;&#9;&#9;"MemberPostalCode": "84070", &#9;&#9;&#9;&#9;&#9;&#9;"MemberPreferredPhone": "801-676-5400", &#9;&#9;&#9;&#9;&#9;&#9;"MemberStateLicense": "0", &#9;&#9;&#9;&#9;&#9;&#9;"OfficeKey": "70083", &#9;&#9;&#9;&#9;&#9;&#9;"OfficeMlsId": "70083", &#9;&#9;&#9;&#9;&#9;&#9;"OfficeName": "Fake Brokerage", &#9;&#9;&#9;&#9;&#9;&#9;"OriginatingSystemMemberKey": "M00000628", &#9;&#9;&#9;&#9;&#9;&#9;"OriginatingSystemName": "UtahRealEstate.com", &#9;&#9;&#9;&#9;&#9;&#9;"MemberMlsAccessYN": true, &#9;&#9;&#9;&#9;&#9;&#9;"ModificationTimestamp": "2020-12-18T16:23:49Z", &#9;&#9;&#9;&#9;&#9;&#9;"OriginalEntryTimestamp": null, &#9;&#9;&#9;&#9;&#9;&#9;"MemberAOR": "Salt Lake Board", &#9;&#9;&#9;&#9;&#9;&#9;"MemberCountry": "", &#9;&#9;&#9;&#9;&#9;&#9;"MemberCountyOrParish": "", &#9;&#9;&#9;&#9;&#9;&#9;"MemberStateLicenseState": "UT", &#9;&#9;&#9;&#9;&#9;&#9;"MemberStateOrProvince": "UT", &#9;&#9;&#9;&#9;&#9;&#9;"MemberStatus": "Active", &#9;&#9;&#9;&#9;&#9;&#9;"MemberType": "MLS Only Broker", &#9;&#9;&#9;&#9;&#9;&#9;"MemberDesignation": "" &#9;&#9;&#9;&#9;} &#9;&#9;] } 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.
Jan ’21