tony-yun
'Unexpected token u in JSON at position 0' 태그의 글 목록

Unexpected token u in JSON at position 0

JavaScript

[JavaScript] SyntaxError: Unexpected token u in JSON at position 0

https://tony-yun.tistory.com/7 [JavaScript] string to boolean 변환법 회사일을 진행하면서 다시 한 번 타입스크립트의 중요성을 깨닫는 순간이 있었다. 유지 보수를 하기 위해 자바스크립트 코드를 수정하고 있었으며, useState에서 boolean으로 설정하고, 이 값을 Async tony-yun.tistory.com 위 필자의 포스트를 보면, 필자가 props값을 string에서 boolean으로 변환하기 위해, JSON.parse('true'); 를 사용했다. 하지만 이 JSON.parse( )괄호안의 값이 없으면 위와 같은 에러: SyntaxError: Unexpected token u in JSON at position 0 를 뱉어낸다. 즉 빈 데이터를..