0
이었다JSON의 직렬화 BEGIN_OBJECT 예상하지만 이것은 내가받은 JSON입니다 STRING
{
"data": "{\"keystring\": \"ag5zfmNvcGFya3NlcnZlcnIUCxIHQ29tbWVudBiAgICAusaBCgw\"}",
"isSucceed": true,
"error": ""
}
그리고이 클래스와 가정 된 코드를 해제 직렬화 :
public class ServerResponse {
private boolean isSucceed;
private String error;
private JSONObject data;
}
//this is the code line responsible for deserialization, responseJson = the JSON above
ServerResponse response = gson.fromJson(responseJson, ServerResponse.class);
들어 어떤 이유로 내가 JsonSyntaxException : 기대 BEGIN_OBJECT하지만 STRING, 나는 ServerResponse 보유하고있는 데이터 객체와 관련 있다고 생각하지만, 유효한 Json으로 그것을 수신 ...
어떤 아이디어?
private JSONObject data;
내 TypeAdapter는 어떻게 작성합니까? – Jjang
@Jjang 그것은 Gson 클래스입니다. [여기에 예제가 있습니다.] (http://www.javacreed.com/gson-typeadapter-example/) –
TypeAdapter가 확실히이 방법입니다. – dharms