0
我有一個RequestModel定義爲同名字段GSON解析
public class RequestModel
{
public class Footage
{
public String date;
public String retrievedAt;
public String videoFileName;
public String availableUntil;
public boolean isAvailable;
}
public class People
{
public String first;
public String last;
}
public static final int USER_BLOCKED = 0;
public static final int USER_ACTIVE = 1;
public static final int USER_WAIT_PIN = 2;
public String _id;
public String status;
public String submittedAt;
public Footage footage;
public People teacher;
public People student;
public ArrayList<MessageModel> messages = new ArrayList<MessageModel>();
public boolean isExpanded = false;
public RequestModel()
{
}
我MessageModel被定義爲
public class MessageModel
{
public String _id;
public String statusMessage;
public String submittedAt;
public RequestModel request;
public String status;
public String timestamp;
public boolean isExpanded = false;
public MessageModel()
{
}
}
我有一個API調用,拉單「RequestModel」項目。然而,該API調用中的消息列表具有「請求」作爲字符串而不是「RequestModel」對象。
有沒有什麼辦法可以讓它解析爲一個不同的名字,或者完全省略它來繞過由於不同類型引起的異常。