Broken out JSON sanitization function.