这是我解析json的方法。问题是,有时它会使错误为null,有时工作正常。谁能告诉我有什么问题吗??
public void requestRestaurantSearchByFilter_list() {
mProgressDialog.show();
StringRequest restrolistrequestfilter = new StringRequest(Request.Method.POST, GlobalData.SEARCHBYFILTERURL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
mProgressDialog.dismiss();
mPaymentMethodList.clear();
mDataList.clear();
mAllList.clear();
mAdapter.notifyDataSetChanged();
Log.e("responcefilterlist....", response);
JSONObject jObject = new JSONObject(response);
if (jObject.getString("status").equals("1")) {
JSONArray jsonArray = jObject.getJSONArray("data");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
PojoRestaurant pojoRestaurant = new PojoRestaurant();
pojoRestaurant.setRestroName(jsonObject.getString("RestaurantName"));
pojoRestaurant.setDeliveryTime(jsonObject.getString("DeliveryTime"));
pojoRestaurant.setPaymentOption(jsonObject.getString("PaymentOptions"));
pojoRestaurant.setMinimumOrder(jsonObject.getString("MinimumOrder"));
pojoRestaurant.setRestroImage(jsonObject.getString("ImageUrl"));
Log.e("retroname", "" + jsonObject.getString("RestaurantName"));
id = jsonObject.getString("ID");
mPaymentMethodList.add(jsonObject.getString("PaymentOptions"));
getpaymentId.add(id);
getListViewId.add(id);
if (jsonObject.getString("OpenStatus").equals("true")) {
pojoRestaurant.setOpenClose("Open");
} else {
pojoRestaurant.setOpenClose("Close");
}
mAllList.add(pojoRestaurant);
mDataList.add(pojoRestaurant);
//mDeliveryList.add(jsonObject.getString("DeliveryTime"));
// mCuisineTypeList.add(jsonObject.getString("RestaurantName"));
}
mListView.setAdapter(mAdapter);
mAdapter.notifyDataSetChanged();
} else {
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Log.e("error", "" + volleyError.getMessage());
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
String foodid = getArguments().getString("FOODID");
String areaid = getArguments().getString("AREAID");
Log.e("foodid", "" + foodid);
Log.e("areaid", "" + areaid);
params.put("DeliveryAreaID", areaid);
params.put("ProvideOffers", "0");
params.put("NewRestaurant", "0");
params.put("PaymentMethod", "0");
params.put("OpenRestaurant", "0");
params.put("FoodID", foodid);
return params;
}
};
RequestQueue restrolistqueuefilter = Volley.newRequestQueue(getContext());
restrolistqueuefilter.add(restrolistrequestfilter);
}
{
"status": 1,
"StatusMessage": "Restaurent List",
"data": [
{
"ID": "7",
"RestaurantName": "Water Lemon",
"MinimumOrder": "20.000",
"DeliveryTime": "30 minutes",
"ImageUrl": "restaurant.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "8",
"RestaurantName": "Casper and Gambini",
"MinimumOrder": "40.000",
"DeliveryTime": "",
"ImageUrl": "restaurant1.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "11",
"RestaurantName": "B L E N D S",
"MinimumOrder": "50.000",
"DeliveryTime": "",
"ImageUrl": "/images/restaurant2.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "12",
"RestaurantName": "khyber Indian Cuisine",
"MinimumOrder": "5.000",
"DeliveryTime": "",
"ImageUrl": "/images/restaurant3.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "13",
"RestaurantName": "Khyber Indian",
"MinimumOrder": "5.000",
"DeliveryTime": "",
"ImageUrl": "http://maaqulat.way2gps.com/images/logo4.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "14",
"RestaurantName": "test",
"MinimumOrder": "10.000",
"DeliveryTime": "",
"ImageUrl": "/images/restaurant4.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "15",
"RestaurantName": "yahoo",
"MinimumOrder": "5.000",
"DeliveryTime": "",
"ImageUrl": null,
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "16",
"RestaurantName": "Khaber",
"MinimumOrder": "3.000",
"DeliveryTime": "",
"ImageUrl": "k0YlxXBVOYZUkhaber.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "17",
"RestaurantName": "Taj mahal",
"MinimumOrder": "5.000",
"DeliveryTime": "",
"ImageUrl": "z4L1JoFkQVjodownload.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "18",
"RestaurantName": "Indian Food",
"MinimumOrder": "10.000",
"DeliveryTime": "",
"ImageUrl": "aMyXtt0YQfKZ5183Indian-Food-Catering-Singapore.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "19",
"RestaurantName": "Shalimar",
"MinimumOrder": "0.500",
"DeliveryTime": "",
"ImageUrl": "5FiXkqgVLJpKshalimar-restaurants-bhendi-bazar-mumbai-e223d.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "20",
"RestaurantName": "Chicken Tikka",
"MinimumOrder": "10.000",
"DeliveryTime": "",
"ImageUrl": "TkM8FCgtIdawChicken-Tikka-banner.png",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "21",
"RestaurantName": "Cafe Arabia",
"MinimumOrder": "10.000",
"DeliveryTime": "",
"ImageUrl": "K90rXIdFZci1joes-cafe-09.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "22",
"RestaurantName": "chinese cuisine",
"MinimumOrder": "25.000",
"DeliveryTime": "",
"ImageUrl": "DhAsHe2olE25chinese.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "23",
"RestaurantName": "Haneen Restaurent",
"MinimumOrder": "0.000",
"DeliveryTime": "",
"ImageUrl": null,
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "24",
"RestaurantName": "karjikar's",
"MinimumOrder": "0.000",
"DeliveryTime": "",
"ImageUrl": "n9dgtenV5lCq240_F_99495426_sdV0B0IGtyULi1rQlGLcbk5HDLGd8HJr.jpg",
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
},
{
"ID": "25",
"RestaurantName": "MyRestaurent",
"MinimumOrder": "10.000",
"DeliveryTime": "",
"ImageUrl": null,
"OpenStatus": true,
"PaymentOptions": "VISA, MasterCard , Maestro , American Express"
}
]
}
尝试将getString替换为optString... as
pojoRestaurant.setRestroName(jsonObject.optString("RestaurantName"));
pojoRestaurant.setDeliveryTime(jsonObject.optString("DeliveryTime"));
pojoRestaurant.setPaymentOption(jsonObject.optString("PaymentOptions"));
pojoRestaurant.setMinimumOrder(jsonObject.optString("MinimumOrder"));
pojoRestaurant.setRestroImage(jsonObject.optString("ImageUrl"));
我使用eclipse IDE编写简单的程序 代码如下 当我试图从命令提示符运行这个程序时,我得到了以下错误 线程“main”java.lang.noClassDeffounder中出现异常错误:RegexTestHarness(错误名称:java_pr/RegexTestHarness)位于java.lang.classloader.defineclass1(本机方法)位于java.lang.cl
,工作正常。谁能告诉我我犯了什么错误吗?
我的签名 改装类别:
这是错误: 运行: Mon Mar25 05:22:00SGT 2019警告:不建议在没有服务器身份验证的情况下建立SSL连接。根据MySQL5.5.45 , 5.6.26和5.7.6要求,如果没有设置显式选项,默认情况下必须建立SSL连接。为了符合不使用SSL的现有应用程序的要求,验证服务器证书属性设置为'false'。您需要通过设置useSSL=false来显式禁用SSL,或者设置useSSL
问题内容: 我正在使用具有以下功能的simplehtmldom: 我这样使用它: 有时,URL可能只是无效的,我想对此进行处理。我以为我可以使用try and catch,但是这没有用,因为它不会抛出异常,它只是给出了这样的php警告: 第39行在上面的代码中。 我如何正确处理此错误,我可以只使用普通条件,它看起来不像返回布尔值。 谢谢大家的帮助 更新资料 这是一个好的解决方案吗? 问题答案: 这
AMQ6235E:缺少目录“H:”。 我无法找到解决这个问题的方法,它正在连接队列,它显示了这个错误。我不能公开我运行的代码,但我可以解释节点脚本将做什么,首先尝试连接队列管理器,然后尝试通道名,主机名,端口名,这里问题是当它需要建立连接而不是得到上面的错误