json字符串转换成List

String gra = JSONUtils.toJSON(getParam("grantee"));//获取json字符串
if(StringUtils.isNotEmpty(gra)){//验证是否为空
	List list = JSONUtils.jsonStringToList(gra);//将json字符串转换成list数组
	for (Iterator iterator = list.iterator(); iterator.hasNext();) {//循环遍历list
		Map row = (Map) iterator.next();//转换成map对象
		Grantee gt = new Grantee();//定义bean
		gt.setAccessType("ALLOW");
		gt.setDistinguishedName(row.get("distinguishedName").toString().trim());
		granteeList.add(gt);//将bean对象添加到list
	}
}

 

你可能感兴趣的:(bean)