关于String json = JSONArray.fromObject(list).toString();报错……
QueryServiceOfAsyncTaskqt=newQueryServiceOfAsyncTask(Constants.WS_NAMESPACE_SJSC,"toS...
QueryServiceOfAsyncTask qt = new QueryServiceOfAsyncTask(
Constants.WS_NAMESPACE_SJSC, "toSaveCheckResult",
Constants.WS_ENDPOINT_SJSC);
qt.setRPCParamName("userId",
SharedPreferencesActivity.read_sp("userid", ""));// 用户id
qt.setRPCParamName("declaration_no", dec);// 申报单号
qt.setRPCParamName("device_id", android.os.Build.SERIAL);// 设备id-Serial_Number
// qt.setRPCParamName("detailJson", List<TcheckresultdetailPO> );// list的Json串
String uptolist ="";
TcheckresultdetailPO po = null;
List<TcheckresultdetailPO> list =null;
String json = JSONArray.fromObject(list).toString();
try {
uptolist = qt.execute().get();
Gson gson = new Gson();
list = gson.fromJson(uptolist, new TypeToken<List<TcheckresultdetailPO>>() {
}.getType());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
不知道为什么fromObject一直报The method fromObject(List<TcheckresultdetailPO>) is undefined for the type JSONArray 展开
Constants.WS_NAMESPACE_SJSC, "toSaveCheckResult",
Constants.WS_ENDPOINT_SJSC);
qt.setRPCParamName("userId",
SharedPreferencesActivity.read_sp("userid", ""));// 用户id
qt.setRPCParamName("declaration_no", dec);// 申报单号
qt.setRPCParamName("device_id", android.os.Build.SERIAL);// 设备id-Serial_Number
// qt.setRPCParamName("detailJson", List<TcheckresultdetailPO> );// list的Json串
String uptolist ="";
TcheckresultdetailPO po = null;
List<TcheckresultdetailPO> list =null;
String json = JSONArray.fromObject(list).toString();
try {
uptolist = qt.execute().get();
Gson gson = new Gson();
list = gson.fromJson(uptolist, new TypeToken<List<TcheckresultdetailPO>>() {
}.getType());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
不知道为什么fromObject一直报The method fromObject(List<TcheckresultdetailPO>) is undefined for the type JSONArray 展开
1个回答
2015-11-03
展开全部
List<TcheckresultdetailPO> list =null;
String json = JSONArray.fromObject(list).toString();
是不是list为null的原因
String json = JSONArray.fromObject(list).toString();
是不是list为null的原因
追问
不等于null的时候也是错的qwq
追答
看不出来为什么。
不过你为什么不统一用GSON呢
String json = JSONArray.fromObject(list).toString();
Gson gson = new Gson();
list = gson.fromJson(uptolist, new TypeToken>() {
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询