java处理json格式数组
String option = ""; // Dom4JHelper.getValueByEleName(queryXml,"option");
option = "[{seq:1,option:\"aaaa\",optionimg:\"aaa\" }," +
"{seq:2,option:\"bbbb\",optionimg:\"vvvv\" }," +
"{seq:3,option:\"ddd\",optionimg:\"ddd\" }]";
//JSONObject jsonObj = JSONObject.fromObject(option);
JSONArray jarr = new JSONArray(option);
for(int i=0;i<jarr.length();i++){
JSONObject jobj = (JSONObject)jarr.get(i);
try{
String optionName = "otpion"+(i+1);
String optionImg = "otpionImg"+(i+1);
int seq = jobj.getInt("seq");
optionName = jobj.getString("option");
optionImg = jobj.getString("optionimg");
logger.info(">>>>"+seq+"="+optionName);
}catch(Exception jex){
jex.printStackTrace();
}
}
补充:web前端 , JavaScript ,