我对使用 JSON 第三方 API FlexJson 还是很陌生。我正在使用这个 jar 将 JSON 反序列化为 java 对象(用户定义)。该类包含两个数组对象。当我使用这个 jar 将此 json 反序列化为我的对象时,会发生错误。错误是“flexjson.JSONException:无法实例化抽象类或接口”。我从带有 REST Web 服务的服务器获取响应字符串是:
{"eobPaymentDetails": [
{"sFileName":"370530424.txt","sCheckNumber":"1QG74316091"},
{"sFileName":"370861045.txt","sCheckNumber":"161018160011247"},
{"sFileName":"370972783.txt","sCheckNumber":"461640055"},
{"sFileName":"370691977.txt","sCheckNumber":"461624870"}
],
"eraPostingDetails":[
{
"iClinicId":97452,
"sPatientAccountNumber":"2994234wer2",
"sDescription":"This corresponding payer is not match with the Patient's current payer",
"sEraName":"371434025.txt",
"sCheckDate":"2016-10-21",
"iPaymentId":370976,
"sPayerName":"Payer",
"iType":3,
"blSent":false,
"sEobNumber":null,
"iId":1,
"sCheckNumber":"046705983",
"sPatientName":"Patient L",
"iEraInfoId":0
}
]}
我反序列化此代码的java代码是:
String sRes = (String) clientResponse.getEntity(String.class);
List<ThsEraPostingDetailsBO> lst = new JSONDeserializer<List<ThsEraPostingDetailsBO>>()
.use(null, ThsEraPostingDetailsBO.class)
.deserialize(sRes);
请帮我解决这个问题。我搜索了很多链接,但我没有得到任何可靠的解决方案。所有帮助将不胜感激。