correctly throw error message upon invalid JSON input.