Yes, it's not the way I would normally encode my Data object, I just legacy a code that was working fine on iOS 16, and now it's broken on iOS 17. But yes, your answer seems to be the correct one, the JSONEncoder stops at the first zero byte.
I'll try a workaround, but in the end, I think I'll change the encoding format to base64. Unfortunately, that implies backend changes for my app and so on.
It's sad that Apple introduced this bug, and it's not fixed yet.