I am seeing an issue where the exact same JSON payload is failing to decode on my iPhone SE (iOS 15.7), but succeeding on my iPhone 15 Pro (iOS 17.6.1).
I am using a default JSONDecoder with no extra configurations.
On both of my devices, I tried inspecting the payload by printing it's contents using different encodings. They both produced the same results:
String(data: data, encoding: .utf8)
returned nil
.
String(data: data, encoding: .utf16)
returned garbage data.
String(data: data, encoding: .ascii)
returned readable ascii.
Upon inspecting the ascii output, I noticed there were some weird characters in the payload; one of the values in the JSON is O³À
. I assume this is the cause of my problems.
I would like to know: why is this happening? Did something change in JSONDecoder
since iOS 15?