본문 바로가기
IT study/06. selfStudy: code error

python error: dictionary 타입을 json으로 읽을 때 한글깨짐현상

by Lacuna028 2021. 9. 3.

결론부터 이야기하면 간단하다

옵션으로 ensure_ascii=False를 주면 된다.

json.dumps(content, indent=4, sort_keys=True, ensure_ascii=False)

 

오류 발생 사유는 json으로 읽어들일때 기본 값이 ensure_ascii=True인데, 아스키 말고도 다른 값을 가지고 있어서 깨짐 현상이 발생한다고 한다.

(참고 링크: https://kibua20.tistory.com/114)