我正在尝试使用 Jackson 库来反序列化 Json 对象,但在 Joda Datetime 格式反序列化中遇到了一些麻烦。
此代码引发以下错误:
无法解析 Lorg/joda/time/base/AbstractInstant;注释类 1557
DataWrapper list = mapper.readValue(response, DataWrapper.class);
我已经尝试找到有关此的内容,但什么也没有。
有完整的代码:
public class DataWrapper {
public List<ScheduleEntry> data;
}
public static class ScheduleEntry {
public long ID;
public DateTime StartDate;
public DateTime EndDate;
public String Description;
}
WebService callWebService = new WebService(SERVICE_URI);
String response = callWebService.webInvoke("/GetScheduleEntrys", params);
ObjectMapper mapper = new ObjectMapper();
try
{
DataWrapper list = mapper.readValue(response, DataWrapper.class);
List<ScheduleEntry> items = list.data;
}
网络服务:
[OperationContract]
[WebInvoke(Method = "POST",
UriTemplate = "GetScheduleEntrys",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
List<ScheduleEntry> GetScheduleEntrys(string Token);
JSON:
[{"Description":"Cliente José","EndDate":"/Date(1353319200000+0000)/","ID":0,"StartDate":"/Date(1353315600000+0000)/"},{" Description":"Cliente Carlos","EndDate":"/Date(1353348000000+0000)/","ID":0,"StartDate":"/Date(1353344400000+0000)/"},{"Description": "Cliente Pedro","EndDate":"/Date(1353513600000+0000)/","ID":0,"StartDate":"/Date(1353510000000+0000)/"},{"Description":"Cliente Marco ","EndDate":"/Date(1353664800000+0000)/","ID":0,"StartDate":"/Date(1353661200000+0000)/"},{"Description":"Cliente José","结束日期”:”/Date(1353319200000+0000)/","ID":0,"StartDate":"/Date(1353315600000+0000)/"},{"Description":"Cliente Carlos","EndDate":"/Date( 1353348000000+0000)/","ID":0,"StartDate":"/Date(1353344400000+0000)/"},{"Description":"Cliente Pedro","EndDate":"/Date(1353513600000+0000 )/","ID":0,"StartDate":"/Date(1353510000000+0000)/"},{"Description":"Cliente Marco","EndDate":"/Date(1353664800000+0000)/" ,"ID":0,"开始日期":"/日期(1353661200000+0000)/"}]/Date(1353348000000+0000)/","ID":0,"StartDate":"/Date(1353344400000+0000)/"},{"Description":"Cliente Pedro","EndDate":"/Date( 1353513600000+0000)/","ID":0,"StartDate":"/Date(1353510000000+0000)/"},{"Description":"Cliente Marco","EndDate":"/Date(1353664800000+0000 )/","ID":0,"StartDate":"/Date(1353661200000+0000)/"}]/Date(1353348000000+0000)/","ID":0,"StartDate":"/Date(1353344400000+0000)/"},{"Description":"Cliente Pedro","EndDate":"/Date( 1353513600000+0000)/","ID":0,"StartDate":"/Date(1353510000000+0000)/"},{"Description":"Cliente Marco","EndDate":"/Date(1353664800000+0000 )/","ID":0,"StartDate":"/Date(1353661200000+0000)/"}]/Date(1353664800000+0000)/","ID":0,"StartDate":"/Date(1353661200000+0000)/"}]/Date(1353664800000+0000)/","ID":0,"StartDate":"/Date(1353661200000+0000)/"}]
完整日志
01-03 17:39:24.700:E/dalvikvm(18494):无法解析 Lorg/joda/time/base/AbstractInstant;注释类 1557 01-03 17:39:28.505: W/dalvikvm(18494): threadid=11: 线程以未捕获的异常退出 (group=0x40c4d1f8) 01-03 17:39:28.650: E/AndroidRuntime(18494): FATAL例外:AsyncTask #1 01-03 17:39:28.650:E/AndroidRuntime(18494):java.lang.RuntimeException:执行 doInBackground() 01-03 17:39:28.650 时发生错误:E/AndroidRuntime(18494) : 在 android.os.AsyncTask$3.done(AsyncTask.java:278) 01-03 17:39:28.650: E/AndroidRuntime(18494): 在 java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java: 273) 01-03 17:39:28.650: E/AndroidRuntime(18494): 在 java.util.concurrent.FutureTask.setException(FutureTask.java:124) 01-03 17:39:28.650: E/AndroidRuntime(18494) :在 java.util.concurrent.FutureTask$Sync。