zoukankan      html  css  js  c++  java
  • 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";
    }

  • 相关阅读:
    HDU 1058
    Codeforces 349C
    HDU 2602
    HDU 2571
    HDU 2955
    HDU 2084
    HDU 1003
    HDU 1506 & 1505
    POJ 1854
    HDU 2095
  • 原文地址:https://www.cnblogs.com/guangxiang/p/10334130.html
Copyright © 2011-2022 走看看