[Android/Error] Expected a string but was BEGIN_OBJECT at line 1 column 42 path $.data

SoyoungLee·2022년 11월 14일
0
post-thumbnail

[Android/Error] Expected a string but was BEGIN_OBJECT at line 1 column 42 path $.data

📌 이슈

Retrofit2 통신 시 JSON response 를 받아와 파싱할 때 통신 실패가 떴다.

java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 42 path $.data

onFailure 된 부분의 메시지를 읽어보니
string 타입을 예상했지만 실제로는 OBJECT 왔다고 한다.

💜 해결 방안

받아오는 객체 타입 부분을 string 에서 object 로 바꾸어 주었다.

수정해주니 data 부분을 잘 파싱해 가져온다.

profile
Android Developer..+ iOS 슬쩍 🌱 ✏️끄적끄적,,개인 기록용 👩🏻‍💻

0개의 댓글