I have a mobile app that uses data imported by my customers. Inevitably they import data cut and pasted from Word or some other program that contains characters that create invalid JSON when they get serialized. The strange part is currently this bad data can be serialized in my C# code and can get sent to my iOS app without issue, it is when it comes back from the iOS device that the JSON seems corrupted.
I need a way to sanitize this imported data to strip out the bad characters to it does not break my JSON.
You do not need to perform ANY sanitization to JSON encode your data. No matter what you feed into your JSON encoder – you will always get valid JSON.