나는 개조 작업에 어려움을 겪고 있습니다. 브라우저에 요청을 게시하면 다음과 같은 요청을받습니다. 개조의 응답에서 json 받기 errorBody
그게 내가 원하는 것입니다. 그러나, 내 애플 리케이션에서 이것을 구문 분석하려고하면 this 스레드에서 응답을 계속했다. this 솔루션을 구현하려고 시도했지만 내 errorBody
은 브라우저의 답변과 비슷하지 않습니다. 이 JSON을 어떻게 구할 수 있습니까?
void handleResponse(Response response){
TextView textView = (TextView)findViewById(R.id.empty_list_tv);
if(response.isSuccessful())
textView.setText(response.toString());
else {
Gson gson = new Gson();
ErrorResponse errorResponse = gson.fromJson(
response.errorBody().toString(),
ErrorResponse.class);
textView.setText(response.errorBody().toString());
}
}
그리고 내 ErrorResponse
:
public class ErrorResponse {
@SerializedName("message")
private String message;
@SerializedName("error")
private Error error;
public String getMessage() {
return message;
}
public Error getError() {
return error;
}
}
'response.errorBody(). toString(),'JSON입니까? – Coder
아니요. 적어도 인식 할 수 없습니다. "[email protected]" – gonczor
JSON이 필요한 GSON의 fromJson에서'errorResponse'를 생성하려고합니다. 너 어디서 잘못 본거야? – Coder