net.sf.json.JSONException: JSONObject["xxxx"] not found

net.sf.json.JSONException: JSONObject[“xxxx”] not found

1、問題描述
JSONObject jsonObject = user.getuser(username);
String userName = jsonObject.getString(“data”);
然後:
net.sf.json.JSONException: JSONObject[“data”] not found…

2、問題解決

   JSONObject jsonObject = user.getuser(username);
   if(jsonObject.has("data")){
         String userName = jsonObject.getString("data");   
   } else{
        system.out.println(“你的業務”)
   }	



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章