判断JSON数组参数值是否为空

public static void main(String[] args) {

String recipt_list_json = "[{'partner':'','partner_fund_no':'0002','sp_user':'test','transaction_id':'12345678','out_trade_no':'77777','receipt_name':'回单','attach':'aaaaa'},{'partner':'00002','partner_fund_no':'0002','sp_user':'test','transaction_id':'12345678','out_trade_no':'77777','receipt_name':'回单','attach':'aaaaa'}]";
ReceiptRequestBean requet = new ReceiptRequestBean();
requet.setRecipt_list(recipt_list_json);
requet.setBatch_no("000");
JSONObject ob = JSONObject.fromObject(requet);
String recipt_list = ob.getString("recipt_list");

JSONArray array = JSONArray.fromObject(recipt_list);
//System.out.println(array.size());
for (int i = 0; i < array.size(); i++)
{
//System.out.println(array.get(i));
Object oo = array.get(i);
JSONObject obb = JSONObject.fromObject(oo);
if ("".equals(obb.getString("partner"))){
System.out.println("参数为空");
}
}


}

你可能感兴趣的:(json)