0
我的android應用程序使用flexjson庫來反序列化通過RESTfull webservice從服務器接收到的json數據字符串。但是,當反序列化我得到錯誤。flexjson.JSONException不知道如何綁定
flexjson.JSONException:[data.status]:不知道如何將Clock_in綁定到類wfa.com.tma.wfa.type.TimeClockStatus中。您可能需要使用ObjectFactory而不是普通類。
這是我的字符串
{
"data":
{
"todayShift":
{
"startTime":"1970-01-01T13:30:00Z",
"endTime":"1970-01-02T00:00:00Z",
"office":
{
"id":1,"name":"Location Test 1"
}
},
"currentTime":"2017-10-12T07:47:11Z",
"status":"Clock_in",
"latestTime":"2017-10-12T07:46:13Z",
"latestOffice":{"id":1,"name":"Location Test 1"}},
"meta":{"type":"TimeClockDto"}
}
這個字符串
public class TimeClockDto implements Serializable
{
private static final long serialVersionUID = 1L;
private TodayShiftDto todayShift;
private String currentTime;
private TimeClockStatus status;
private String latestTime;
private BaseLocationDto latestOffice;
public TimeClockDto(TodayShiftDto todayShift, String currentTime,
TimeClockStatus status, String latestClockInTime,
BaseLocationDto latestOffice)
{
this.todayShift = todayShift;
this.currentTime = currentTime;
this.status = status;
this.latestTime = latestClockInTime;
this.latestOffice = latestOffice;
}
//getter, setter
}
`和反序列化代碼
的DTO和枚舉類
public enum TimeClockStatus
{
Clock_in, Clock_out;
}