detect invalid UTF-8 encoding in JSON strings, throw appropriate error