본문 바로가기
파이썬

파이썬 Python 3 : JSON을 직렬화 할 수 없음

by º기록 2020. 11. 7.
반응형
TypeError: b'Pizza is a flatbread generally topped with tomato sauce and cheese and baked in an oven. It is commonly topped with a selection of meats, vegetables and condiments. The term was first recorded in the 10th century, in a Latin manuscript from Gaeta in Central Italy. The modern pizza was invented in Naples, Italy, and the dish and its variants have since become popular in many areas of the world.\nIn 2009, upon Italy\'s request, Neapolitan pizza was safeguarded in the European Union as a Traditional Speciality Guaranteed dish. The Associazione Verace Pizza Napoletana (the True Neapolitan Pizza Association) is a non-profit organization founded in 1984 with headquarters in Naples. It promotes and protects the "true Neapolitan pizza".\nPizza is sold fresh, frozen or in portions, and is a common fast food item in North America and the United Kingdom. Various types of ovens are used to cook them and many varieties exist. Several similar dishes are prepared from ingredients commonly used in pizza preparation, such as calzone and stromboli.' is not JSON serializable

나는 이것을 JSON 문자열에 추가하는 프로그램을 가지고 있는데, 이것은 대부분의 텍스트 문자열에서 잘 작동하지만 이것은 분명히 아닙니다. 왜 안되는지 또는 어떻게 고칠 지 말할 수 있습니까?

 

해결 방법

 

이것은 문자열이 아니라 바이트 시퀀스입니다. JSON은 바이트 시퀀스가 ​​아닌 유니 코드 문자열을 처리하는 방법 만 알고 있습니다. 유니 코드 ( json.dumps (x.decode ( "utf-8")) )로 변환하거나 정수 배열 ( json.dumps (list (x)) ).

 

참조 페이지 https://stackoverflow.com/questions/36212905

 

 

반응형

댓글