java判断jsonObject和jsonArray是否为空


resJsonObj = {"res":"0","msg":"","data":{"Name": "张三","Phone": "15000000003","relName": "系统管理员权限","Navigation": []}}

1.判断data是否为空

JSONObject dataJson =resJsonObj .getJSONObject("data");

if(dataJson == null || dataJson.isEmpty() || dataJson.isNullObject() || "null".equals(dataJson)){
               return "error";
}

2.判断Nacigation数组是否为空

JSONArray dataNJson = dataJson.getJSONArray("Navigation");
if(dataNJson.isEmpty()||dataNJson.size()<1){
  return "error";
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM