如何在JSON响应没有个行业打印信息? [英] How to Print Message when Json Response has no fileds?
本文介绍了如何在JSON响应没有个行业打印信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用本教程 HTTP://www.androidhive。信息/ 2012/01 / Android的JSON的解析教程/ 以JSON解析,并在我的应用程序的响应,一切工作正常,但如果响应没有提交,假设按照本教程中如果有像效应初探{接触:},这意味着没有数组那么如何打印敬酒,如果没有领域有
I am using this tutorial http://www.androidhive.info/2012/01/android-json-parsing-tutorial/ for json parsing,and in my app response and everything works fine,but what if response has no filed,suppose as per this tutorial if it has reponse like {"contacts":""},it means no array so how to print toast if no fields there.
推荐答案
根据此例尝试这个..
as per this example try this..
protected void onPostExecute(Void result) {
super.onPostExecute(result);
if(contacts == null || contacts.length() == 0){
Toast.makeText(getApplicationContext(), "No Data",Toast.LENGTH_SHORT).show();
}
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
}
这篇关于如何在JSON响应没有个行业打印信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文