手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

如何判断json对象为空

时间:2024-10-14 20:51:36

1、首先是Java巳呀屋饔,resJsonObj = {}1.判断data是否为空JSONObject dataJson =resJsonObj.getJSONObject("data");//下边判断是否为NULL!!!if(dataJson == null || dataJson.isEmpty() || dataJson.isNullObject() || "null".equals(dataJson)){ return "error";}

2、JS:varresJson={data:"&孥恶膈茯quot;};if(resJson&&resJson.data岿滗欣橡!=""){alert("resJson不为空")}else{alert("resJson为空")}

3、jQuery:jQuery.isEmptyObject(obj)

© 手抄报圈