-
JSON - parsing error컴퓨터/JavaScript_typescript 2020. 1. 21. 10:23
* JSON parsing error
ex 1) \n, \r
JSONObj = JSONObj.replace(/\n/gi, '\\n');
JSONObj = JSONObj.replace(/\r/gi, '\\r');ex 2) ' 작은 따옴표를 "" 큰 따옴표로 바꿔야 한다.
JSONObj = JSON.parse(JSONObj.replace(/'/g,'"'))
'컴퓨터 > JavaScript_typescript' 카테고리의 다른 글
[weird JavaScript] type coercion, ==와 > < operator, ++, --도 type coercion 사용 (0) 2020.02.11 [javascript] Objects.keys(array), Object.getOwnPropertyNames(array), Object.entries(array) (0) 2020.02.06 동적 타이핑, 타입 체크 (0) 2020.01.19 throw Error (0) 2020.01.19 Template, Tagged Template literals, 함수이름`HTML내용` (0) 2020.01.19