基本的にWebサービスからの応答である次のクラスがあります。
public class WSGenericMessage<T> implements Serializable {
private static final long serialVersionUID = 1L;
private Boolean ResponseCode;
private String ResponseMessage;
private Class<T> ResponseData;
public Boolean getResponseCode() {
return ResponseCode;
}
public void setResponseCode(Boolean responseCode) {
ResponseCode = responseCode;
}
public String getResponseMessage() {
return ResponseMessage;
}
public void setResponseMessage(String responseMessage) {
ResponseMessage = responseMessage;
}
public Class<T> getResponseData() {
return ResponseData;
}
public void setResponseData(Class<T> responseData) {
ResponseData = responseData;
}
}
次の方法でjson文字列を逆シリアル化することは可能ですか:
Gson gson = new Gson();
Type type = new TypeToken<WSGenericMessage<String>>(){}.getType();
gson.fromJson(result, type);
私は得ています:
java.lang.UnsupportedOperationException: Attempted to deserialize a java.lang.Class. Forgot to register a type adapter?